From fe973af99c0af10afb615c5c0ad2cbf812bd8e97 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 10 Aug 2025 23:28:43 -0400 Subject: [PATCH] tape: Test dynamic encoding and decoding of signed integers --- tape/dynamic_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tape/dynamic_test.go b/tape/dynamic_test.go index 19575bd..d942757 100644 --- a/tape/dynamic_test.go +++ b/tape/dynamic_test.go @@ -9,7 +9,7 @@ import tu "git.tebibyte.media/sashakoshka/hopp/internal/testutil" func TestEncodeAnyInt(test *testing.T) { err := testEncodeAny(test, uint8(0xCA), LI.WithCN(0), tu.S(0xCA)) if err != nil { test.Fatal(err) } - err = testEncodeAny(test, 400, LI.WithCN(3), tu.S( + err = testEncodeAny(test, 400, LSI.WithCN(3), tu.S( 0, 0, 0x1, 0x90, )) if err != nil { test.Fatal(err) } @@ -22,15 +22,16 @@ func TestEncodeAnyTable(test *testing.T) { 0x0000: "hi!", 0xFFFF: []uint16 { 0xBEE5, 0x7777 }, 0x1234: [][]uint16 { []uint16 { 0x5 }, []uint16 { 0x17, 0xAAAA} }, - }, KTV.WithCN(0), tu.S(5).AddVar( + 0x2345: [][]int16 { []int16 { 0x5 }, []int16 { 0x17, -0xAAA } }, + }, KTV.WithCN(0), tu.S(6).AddVar( []byte { 0xF3, 0xB9, - byte(LI.WithCN(3)), + byte(LSI.WithCN(3)), 0, 0, 0, 1, }, []byte { 0x01, 0x02, - byte(LI.WithCN(3)), + byte(LSI.WithCN(3)), 0, 0, 0, 2, }, []byte { @@ -52,6 +53,15 @@ func TestEncodeAnyTable(test *testing.T) { 0, 0x17, 0xAA, 0xAA, }, + []byte { + 0x23, 0x45, + byte(OTA.WithCN(0)), 2, byte(OTA.WithCN(0)), + 1, byte(LSI.WithCN(1)), + 0, 0x5, + 2, byte(LSI.WithCN(1)), + 0, 0x17, + 0xF5, 0x56, + }, )) if err != nil { test.Fatal(err) } }