tape: Test U16CastSafe

This commit is contained in:
2025-01-19 15:41:43 -05:00
parent c748ca2223
commit aac5266c0c
2 changed files with 44 additions and 0 deletions

27
metadapta_test.go Normal file
View File

@@ -0,0 +1,27 @@
package hopp
import "bytes"
import "slices"
import "testing"
func TestDecodeMessageA(test *testing.T) {
transID, method, payload, err := decodeMessageA(bytes.NewReader([]byte {
0x58, 0x00, 0xFE, 0xAB, 0xC3, 0x10, 0x4F, 0x04,
0x6B, 0x12,
0x00, 0x06,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
}))
if err != nil {
test.Fatal(err)
}
if got, correct := transID, int64(0x5800FEABC3104F04); got != correct {
test.Fatalf("not equal: %v %v", got, correct)
}
if got, correct := method, uint16(0x6B12); got != correct {
test.Fatalf("not equal: %v %v", got, correct)
}
correctPayload := []byte { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }
if got, correct := payload, correctPayload; !slices.Equal(got, correct) {
test.Fatalf("not equal: %v %v", got, correct)
}
}