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

Function TestSerializeInterface

go/fory/fory_test.go:132–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func TestSerializeInterface(t *testing.T) {
133 for _, referenceTracking := range []bool{false, true} {
134 fory := NewFory(WithXlang(true), WithCompatible(false), WithRefTracking(referenceTracking))
135 var a any
136 a = -1
137 serde(t, fory, a)
138 // Use int64 for interface values since fory deserializes integers to int64 for cross-language compatibility
139 b := []any{int64(1), int64(2), "str"}
140 serde(t, fory, b)
141 var newB []any
142 serDeserializeTo(t, fory, b, &newB)
143 require.Equal(t, b, newB)
144 // pointer to interface is not allowed.
145 _, err := fory.Marshal(&a)
146 require.Error(t, err)
147 }
148}
149
150func TestSerializePtr(t *testing.T) {
151 for _, referenceTracking := range []bool{false, true} {

Callers

nothing calls this directly

Calls 10

MarshalMethod · 0.95
NewForyFunction · 0.85
WithXlangFunction · 0.85
WithCompatibleFunction · 0.85
WithRefTrackingFunction · 0.85
serdeFunction · 0.85
serDeserializeToFunction · 0.85
int64Function · 0.50
EqualMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected