tape: Test U16CastSafe
This commit is contained in:
27
metadapta_test.go
Normal file
27
metadapta_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user