@@ -38,6 +38,29 @@ func TestEquipment_UniqueID(t *testing.T) {
3838 assert .NotEqual (t , NewEquipment (EqAK47 ).UniqueID (), NewEquipment (EqAK47 ).UniqueID (), "UniqueIDs of different equipment instances should be different" )
3939}
4040
41+ func TestEquipment_AmmoInMagazine (t * testing.T ) {
42+ wep := & Equipment {
43+ Type : EqAK47 ,
44+ Entity : entityWithProperty ("m_iClip1" , st.PropertyValue {IntVal : 31 }),
45+ }
46+
47+ // returned value should be minus 1, m_iClip1 is always 1 more than the actual number of bullets
48+ assert .Equal (t , 30 , wep .AmmoInMagazine ())
49+ }
50+
51+ func TestEquipment_AmmoInMagazine_NotFound (t * testing.T ) {
52+ entity := entityWithID (1 )
53+ entity .On ("PropertyValue" , "m_iClip1" ).Return (st.PropertyValue {}, false )
54+
55+ wep := & Equipment {
56+ Type : EqAK47 ,
57+ Entity : entity ,
58+ }
59+
60+ // returned value should be minus 1, m_iClip1 is always 1 more than the actual number of bullets
61+ assert .Equal (t , - 1 , wep .AmmoInMagazine ())
62+ }
63+
4164func TestEquipment_AmmoInMagazine_Grenade (t * testing.T ) {
4265 wep := & Equipment {
4366 Type : EqFlash ,
@@ -46,6 +69,24 @@ func TestEquipment_AmmoInMagazine_Grenade(t *testing.T) {
4669 assert .Equal (t , 1 , wep .AmmoInMagazine ())
4770}
4871
72+ func TestEquipment_AmmoInMagazine_EntityNil (t * testing.T ) {
73+ wep := & Equipment {
74+ Type : EqAK47 ,
75+ }
76+
77+ assert .Equal (t , 0 , wep .AmmoInMagazine ())
78+ }
79+
80+ func TestEquipment_AmmoReserve (t * testing.T ) {
81+ entity := entityWithProperty ("m_iPrimaryReserveAmmoCount" , st.PropertyValue {IntVal : 60 })
82+ wep := & Equipment {
83+ Type : EqAK47 ,
84+ Entity : entity ,
85+ }
86+
87+ assert .Equal (t , 60 , wep .AmmoReserve ())
88+ }
89+
4990func TestEquipment_AmmoReserve_Grenade (t * testing.T ) {
5091 owner := new (Player )
5192 owner .AmmoLeft [1 ] = 2
@@ -60,14 +101,39 @@ func TestEquipment_AmmoReserve_Grenade(t *testing.T) {
60101 assert .Equal (t , 1 , wep .AmmoReserve ())
61102}
62103
63- func TestEquipment_AmmoReserve2_Grenade_OwnerNil (t * testing.T ) {
104+ func TestEquipment_AmmoReserve_Grenade_OwnerNil (t * testing.T ) {
64105 wep := & Equipment {
65106 Type : EqFlash ,
66107 }
67108
68109 assert .Equal (t , 0 , wep .AmmoReserve ())
69110}
70111
112+ func TestEquipment_AmmoReserve_EntityNil (t * testing.T ) {
113+ wep := & Equipment {
114+ Type : EqAK47 ,
115+ }
116+
117+ assert .Equal (t , 0 , wep .AmmoReserve ())
118+ }
119+
120+ func TestEquipment_ZoomLevel (t * testing.T ) {
121+ wep := & Equipment {
122+ Type : EqAK47 ,
123+ Entity : entityWithProperty ("m_zoomLevel" , st.PropertyValue {IntVal : 2 }),
124+ }
125+
126+ assert .Equal (t , ZoomFull , wep .ZoomLevel ())
127+ }
128+
129+ func TestEquipment_ZoomLevel_EntityNil (t * testing.T ) {
130+ wep := & Equipment {
131+ Type : EqAK47 ,
132+ }
133+
134+ assert .Equal (t , ZoomLevel (0 ), wep .ZoomLevel ())
135+ }
136+
71137func TestEquipmentAlternative (t * testing.T ) {
72138 assert .Equal (t , EqUSP , EquipmentAlternative (EqP2000 ))
73139 assert .Equal (t , EqCZ , EquipmentAlternative (EqP250 ))
0 commit comments