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

Function TestReadUTF16LE_OddByteCount

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

Source from the content-addressed store, hash-verified

38}
39
40func TestReadUTF16LE_OddByteCount(t *testing.T) {
41 // Test edge case: odd byte count (malformed UTF-16 data).
42 // This should return a typed decode error rather than silently truncating.
43 data := []byte{0x48, 0x00, 0x69, 0x00, 0xFF}
44 buf := NewByteBuffer(data)
45 err := &Error{}
46
47 result := readUTF16LE(buf, 5, err)
48
49 require.True(t, err.HasError())
50 require.Equal(t, ErrKindInvalidUTF16String, err.Kind())
51 require.Equal(t, "", result)
52}
53
54func TestReadUTF16LE_SingleByte(t *testing.T) {
55 // Test edge case: single byte (no complete UTF-16 code units)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected