MCPcopy Create free account
hub / github.com/apache/fory / TestReadUTF16LE_EvenByteCount

Function TestReadUTF16LE_EvenByteCount

go/fory/string_test.go:26–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestReadUTF16LE_EvenByteCount(t *testing.T) {
27 // Test normal case: even byte count (valid UTF-16)
28 // "Hi" in UTF-16LE: 'H'=0x0048, 'i'=0x0069
29 // Little-endian bytes: 48 00 69 00
30 data := []byte{0x48, 0x00, 0x69, 0x00}
31 buf := NewByteBuffer(data)
32 err := &Error{}
33
34 result := readUTF16LE(buf, 4, err)
35
36 require.False(t, err.HasError())
37 require.Equal(t, "Hi", result)
38}
39
40func TestReadUTF16LE_OddByteCount(t *testing.T) {
41 // Test edge case: odd byte count (malformed UTF-16 data).

Callers

nothing calls this directly

Calls 4

HasErrorMethod · 0.95
NewByteBufferFunction · 0.85
readUTF16LEFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected