Skip to content

Commit 8b9abab

Browse files
committed
feat: add isPOV/decodeInt64 tests
1 parent 71dfb93 commit 8b9abab

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/demoinfocs/parser_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ func TestParser_GameState(t *testing.T) {
2323
assert.Equal(t, gs, (&parser{gameState: gs}).GameState())
2424
}
2525

26+
func TestParser_IsPOV(t *testing.T) {
27+
p := &parser{recordingPlayerSlot: -1}
28+
29+
assert.Equal(t, false, p.IsPOV())
30+
31+
p.recordingPlayerSlot = 3
32+
33+
assert.Equal(t, true, p.IsPOV())
34+
}
35+
2636
func TestParser_CurrentTime(t *testing.T) {
2737
p := &parser{
2838
tickInterval: 2,

pkg/demoinfocs/sendtables/propdecoder_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package sendtables
22

33
import (
4+
"bytes"
5+
"encoding/binary"
46
"testing"
57

8+
bit "github.com/markus-wa/demoinfocs-golang/v3/internal/bitread"
69
"github.com/stretchr/testify/assert"
710
)
811

@@ -11,6 +14,18 @@ func TestPropertyValue_BoolVal(t *testing.T) {
1114
assert.False(t, PropertyValue{IntVal: 0}.BoolVal())
1215
}
1316

17+
func TestPropertyValue_Int64Val(t *testing.T) {
18+
expected := int64(76561198000697560)
19+
prop := &property{entry: &flattenedPropEntry{prop: &sendTableProperty{rawType: propTypeInt64, flags: propFlagUnsigned, numberOfBits: 64}}}
20+
b := make([]byte, 8)
21+
binary.LittleEndian.PutUint64(b, uint64(expected))
22+
r := bit.NewSmallBitReader(bytes.NewReader(b))
23+
24+
propDecoder.decodeProp(prop, r)
25+
26+
assert.Equal(t, expected, prop.value.Int64Val)
27+
}
28+
1429
func TestDecodeProp_UnknownType(t *testing.T) {
1530
prop := &property{entry: &flattenedPropEntry{prop: &sendTableProperty{rawType: -1}}}
1631

0 commit comments

Comments
 (0)