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

Function TestSliceDemo

go/fory/tests/generator_test.go:65–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestSliceDemo(t *testing.T) {
66 // 1. Create test instance with various slice types
67 original := &SliceDemo{
68 IntSlice: []int32{10, 20, 30, 40, 50},
69 StringSlice: []string{"hello", "world", "fory", "slice"},
70 FloatSlice: []float64{1.1, 2.2, 3.3, 4.4, 5.5},
71 BoolSlice: []bool{true, false, true, false},
72 }
73
74 // Validate original data structure (quick sanity check)
75 assert.NotEmpty(t, original.IntSlice, "IntSlice should not be empty")
76 assert.NotEmpty(t, original.StringSlice, "StringSlice should not be empty")
77 assert.NotEmpty(t, original.FloatSlice, "FloatSlice should not be empty")
78 assert.NotEmpty(t, original.BoolSlice, "BoolSlice should not be empty")
79
80 // 2. SerializeWithCallback using generated code
81 f := fory.NewFory(fory.WithXlang(false), fory.WithCompatible(false), fory.WithRefTracking(true))
82 data, err := f.Marshal(original)
83 require.NoError(t, err, "Serialization should not fail")
84 require.NotEmpty(t, data, "Serialized data should not be empty")
85 assert.Greater(t, len(data), 0, "Serialized data should have positive length")
86
87 // 3. DeserializeWithCallbackBuffers using generated code
88 var result *SliceDemo
89 err = f.Unmarshal(data, &result)
90 require.NoError(t, err, "Deserialization should not fail")
91 require.NotNil(t, result, "Deserialized result should not be nil")
92
93 // 4. Verify that serializer is properly registered and can be retrieved
94 sliceSerializer := NewSerializerFor_SliceDemo()
95 assert.NotNil(t, sliceSerializer, "Serializer should not be nil")
96}
97
98func TestDynamicSliceDemo(t *testing.T) {
99 // 1. Create test instance with various any types

Callers

nothing calls this directly

Calls 4

MarshalMethod · 0.95
UnmarshalMethod · 0.95
GreaterMethod · 0.80

Tested by

no test coverage detected