unify-byte-counts #21

Merged
sashakoshka merged 16 commits from unify-byte-counts into main 2025-10-13 08:49:49 -06:00
2 changed files with 50 additions and 0 deletions
Showing only changes of commit b44d364f0f - Show all commits

View File

@@ -296,3 +296,42 @@ func TestPeekSliceOnce(test *testing.T) {
test.Fatalf("wrong n: %d != %d", got, correct)
}
}
func TestTagAny(test *testing.T) {
cases := [][2]any {
[2]any { LSI.WithCN(3), int(9) },
[2]any { LSI.WithCN(0), int8(9) },
[2]any { LSI.WithCN(1), int16(9) },
[2]any { LSI.WithCN(3), int32(9) },
[2]any { LSI.WithCN(7), int64(9) },
[2]any { LI.WithCN(3), uint(9) },
[2]any { LI.WithCN(0), uint8(9) },
[2]any { LI.WithCN(1), uint16(9) },
[2]any { LI.WithCN(3), uint32(9) },
[2]any { LI.WithCN(7), uint64(9) },
[2]any { FP.WithCN(3), float32(9) },
[2]any { FP.WithCN(7), float64(9) },
[2]any { SBA.WithCN(12), "small string" },
[2]any { SBA.WithCN(12), []byte("small string") },
[2]any { LBA.WithCN(0), "this is a very long string that is long" },
[2]any { LBA.WithCN(0), []byte("this is a very long string that is long") },
[2]any { LBA.WithCN(1), lipsum },
[2]any { OTA.WithCN(0), []int { 1, 2, 3, 4, 5 } },
[2]any { OTA.WithCN(0), []string { "1, 2, 3, 4, 5" } },
[2]any { KTV.WithCN(0), map[uint16] any {
0: 1,
1: "wow",
2: 10.238,
45: -9,
9: map[uint16] any { },
}},
}
for _, cas := range cases {
test.Log(cas)
got, err := TagAny(cas[1])
if err != nil { test.Fatal(err) }
if correct := cas[0].(Tag); correct != got {
test.Fatalf("wrong tag: %v != %v", got, correct)
}
}
}

11
tape/strings.go Normal file
View File

@@ -0,0 +1,11 @@
package tape
const lipsum = `Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.
Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.`