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

Function TestSerializeStructSimple

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

Source from the content-addressed store, hash-verified

268}
269
270func TestSerializeStructSimple(t *testing.T) {
271 for _, referenceTracking := range []bool{false, true} {
272 // Use WithXlang(false) for native Go mode where nil slices/maps are preserved
273 fory := NewFory(WithXlang(false), WithRefTracking(referenceTracking), WithCompatible(false))
274 type A struct {
275 F1 []string
276 }
277 require.Nil(t, fory.RegisterStructByName(A{}, "example.A"))
278 serde(t, fory, A{})
279 serde(t, fory, &A{})
280 serde(t, fory, A{F1: []string{"str1", "", "str2"}})
281 serde(t, fory, &A{F1: []string{"str1", "", "str2"}})
282
283 type SimpleB struct {
284 F1 []string
285 F2 map[string]int32
286 }
287 require.Nil(t, fory.RegisterStructByName(SimpleB{}, "example.SimpleB"))
288 serde(t, fory, SimpleB{})
289 serde(t, fory, SimpleB{
290 F1: []string{"str1", "", "str2"},
291 F2: map[string]int32{
292 "k1": 1,
293 "k2": 2,
294 },
295 })
296 }
297}
298
299type explicitRegistrationUser struct {
300 Name string

Callers

nothing calls this directly

Calls 6

RegisterStructByNameMethod · 0.95
NewForyFunction · 0.85
WithXlangFunction · 0.85
WithRefTrackingFunction · 0.85
WithCompatibleFunction · 0.85
serdeFunction · 0.85

Tested by

no test coverage detected