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

Function TestNamedStructRegistrationCoversPointer

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

Source from the content-addressed store, hash-verified

301}
302
303func TestNamedStructRegistrationCoversPointer(t *testing.T) {
304 fory := NewFory(WithXlang(true), WithCompatible(false), WithRefTracking(false))
305 require.NoError(t, fory.RegisterStructByName(explicitRegistrationUser{}, "example.User"))
306
307 value := explicitRegistrationUser{Name: "alice"}
308 buf := NewByteBuffer(nil)
309 require.NoError(t, fory.SerializeWithCallback(buf, value, nil))
310 var decodedValue explicitRegistrationUser
311 require.NoError(t, fory.DeserializeWithCallbackBuffers(
312 NewByteBuffer(buf.GetByteSlice(0, buf.WriterIndex())),
313 &decodedValue,
314 nil))
315 require.Equal(t, value, decodedValue)
316
317 data, err := fory.Marshal(&value)
318 require.NoError(t, err)
319 var decodedPointer explicitRegistrationUser
320 require.NoError(t, fory.Unmarshal(data, &decodedPointer))
321 require.Equal(t, value, decodedPointer)
322}
323
324func TestUnregisteredStructSerializationFails(t *testing.T) {
325 value := explicitRegistrationUser{Name: "bob"}

Callers

nothing calls this directly

Calls 13

RegisterStructByNameMethod · 0.95
SerializeWithCallbackMethod · 0.95
GetByteSliceMethod · 0.95
WriterIndexMethod · 0.95
MarshalMethod · 0.95
UnmarshalMethod · 0.95
NewForyFunction · 0.85
WithXlangFunction · 0.85
WithCompatibleFunction · 0.85
WithRefTrackingFunction · 0.85
NewByteBufferFunction · 0.85

Tested by

no test coverage detected