55
66 "github.com/stretchr/testify/assert"
77
8+ "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/constants"
89 st "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/sendtables"
910)
1011
@@ -19,6 +20,29 @@ func TestHostage_Leader(t *testing.T) {
1920 assert .Equal (t , player , hostage .Leader ())
2021}
2122
23+ func TestHostage_LeaderWithInvalidHandleS2 (t * testing.T ) {
24+ player := new (Player )
25+ player .EntityID = 10
26+ provider := demoInfoProviderMock {
27+ playersByHandle : map [uint64 ]* Player {10 : player },
28+ isSource2 : true ,
29+ }
30+ hostage := hostageWithProperties ([]fakeProp {
31+ {
32+ propName : "m_leader" ,
33+ value : st.PropertyValue {Any : uint64 (constants .InvalidEntityHandleSource2 )},
34+ isNil : false ,
35+ },
36+ {
37+ propName : "m_hHostageGrabber" ,
38+ value : st.PropertyValue {Any : uint64 (10 )},
39+ isNil : false ,
40+ },
41+ }, provider )
42+
43+ assert .Equal (t , player , hostage .Leader ())
44+ }
45+
2246func TestHostage_State (t * testing.T ) {
2347 hostage := hostageWithProperty ("m_nHostageState" , st.PropertyValue {IntVal : int (HostageStateFollowingPlayer )}, demoInfoProviderMock {})
2448
@@ -34,3 +58,7 @@ func TestHostage_Health(t *testing.T) {
3458func hostageWithProperty (propName string , value st.PropertyValue , provider demoInfoProviderMock ) * Hostage {
3559 return & Hostage {Entity : entityWithProperty (propName , value ), demoInfoProvider : provider }
3660}
61+
62+ func hostageWithProperties (properties []fakeProp , provider demoInfoProviderMock ) * Hostage {
63+ return & Hostage {Entity : entityWithProperties (properties ), demoInfoProvider : provider }
64+ }
0 commit comments