@@ -428,7 +428,7 @@ func TestPlayer_Velocity(t *testing.T) {
428428 assert .Equal (t , expected , pl .Velocity ())
429429}
430430
431- func TestPlayer_VelocityS2 ( t * testing. T ) {
431+ func createPlayerForVelocityTest () * Player {
432432 controllerEntity := entityWithProperties ([]fakeProp {
433433 {propName : "m_hPlayerPawn" , value : st.PropertyValue {Any : uint64 (1 ), S2 : true }},
434434 })
@@ -446,10 +446,23 @@ func TestPlayer_VelocityS2(t *testing.T) {
446446 1 : pawnEntity ,
447447 },
448448 }
449- pl .LastPositions = []r3.Vector {{X : 10 , Y : 200 , Z : 0 }, {X : 20 , Y : 300 , Z : 0 }}
450449 pl .demoInfoProvider = demoInfoProvider
451450
452- expected := r3.Vector {X : 640 , Y : 6400 , Z : 0 }
451+ return pl
452+ }
453+
454+ func TestPlayer_VelocityS2 (t * testing.T ) {
455+ pl := createPlayerForVelocityTest ()
456+ pl .LastPositions = []r3.Vector {{X : 10 , Y : 200 , Z : 50 }, {X : 20 , Y : 300 , Z : 100 }}
457+
458+ expected := r3.Vector {X : 640 , Y : 6400 , Z : 3200 }
459+ assert .Equal (t , expected , pl .Velocity ())
460+ }
461+
462+ func TestPlayer_VelocityS2WithoutPositions (t * testing.T ) {
463+ pl := createPlayerForVelocityTest ()
464+
465+ expected := r3.Vector {X : 0 , Y : 0 , Z : 0 }
453466 assert .Equal (t , expected , pl .Velocity ())
454467}
455468
0 commit comments