TestSerializeAny tests the Serialize/Deserialize methods
(t *testing.T)
| 90 | |
| 91 | // TestSerializeAny tests the Serialize/Deserialize methods |
| 92 | func TestSerializeAny(t *testing.T) { |
| 93 | f := New(fory.WithXlang(false), fory.WithRefTracking(true), fory.WithCompatible(false)) |
| 94 | |
| 95 | t.Run("Primitives", func(t *testing.T) { |
| 96 | data, err := f.Serialize(int32(42)) |
| 97 | require.NoError(t, err) |
| 98 | |
| 99 | var result int32 |
| 100 | err = f.Deserialize(data, &result) |
| 101 | require.NoError(t, err) |
| 102 | require.Equal(t, int32(42), result) |
| 103 | }) |
| 104 | |
| 105 | t.Run("String", func(t *testing.T) { |
| 106 | data, err := f.Serialize("hello") |
| 107 | require.NoError(t, err) |
| 108 | |
| 109 | var result string |
| 110 | err = f.Deserialize(data, &result) |
| 111 | require.NoError(t, err) |
| 112 | require.Equal(t, "hello", result) |
| 113 | }) |
| 114 | } |
| 115 | |
| 116 | // TestDeserialize tests the Deserialize generic function |
| 117 | func TestDeserialize(t *testing.T) { |
nothing calls this directly
no test coverage detected