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

Function TestFloat16Primitive

go/fory/primitive_test.go:28–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestFloat16Primitive(t *testing.T) {
29 f := New(WithXlang(true), WithCompatible(false))
30 f16 := float16.Float16FromFloat32(3.14)
31
32 // Directly serialize a float16 value
33 data, err := f.Serialize(f16)
34 require.NoError(t, err)
35
36 var res float16.Float16
37 err = testDeserialize(t, f, data, &res)
38 require.NoError(t, err)
39
40 require.True(t, f16.Equal(res))
41
42 // Value check (approximate)
43 require.InDelta(t, 3.14, res.Float32(), 0.01)
44}
45
46func TestFloat16PrimitiveSliceDirect(t *testing.T) {
47 // Tests serializing a slice as a root object

Callers

nothing calls this directly

Calls 7

Float32Method · 0.95
WithXlangFunction · 0.85
WithCompatibleFunction · 0.85
testDeserializeFunction · 0.85
NewFunction · 0.70
SerializeMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected