(t *testing.T)
| 389 | } |
| 390 | |
| 391 | func TestSerializeStruct(t *testing.T) { |
| 392 | for _, referenceTracking := range []bool{false, true} { |
| 393 | fory := NewFory(WithXlang(true), WithCompatible(false), WithRefTracking(referenceTracking)) |
| 394 | require.Nil(t, fory.RegisterStructByName(Bar{}, "example.Bar")) |
| 395 | serde(t, fory, &Bar{}) |
| 396 | bar := Bar{F1: 1, F2: "str"} |
| 397 | serde(t, fory, bar) |
| 398 | serde(t, fory, &bar) |
| 399 | |
| 400 | type A struct { |
| 401 | F1 Bar |
| 402 | F2 any |
| 403 | } |
| 404 | require.Nil(t, fory.RegisterStructByName(A{}, "example.A")) |
| 405 | serde(t, fory, A{}) |
| 406 | serde(t, fory, &A{}) |
| 407 | // Use int64 for any fields since xlang deserializes integers to int64 |
| 408 | serde(t, fory, A{F1: Bar{F1: 1, F2: "str"}, F2: int64(-1)}) |
| 409 | serde(t, fory, &A{F1: Bar{F1: 1, F2: "str"}, F2: int64(-1)}) |
| 410 | |
| 411 | require.Nil(t, fory.RegisterStructByName(Foo{}, "example.Foo")) |
| 412 | foo := newFoo() |
| 413 | serde(t, fory, foo) |
| 414 | serde(t, fory, &foo) |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | func TestSerializeCircularReference(t *testing.T) { |
| 419 | fory := NewFory(WithXlang(true), WithCompatible(false), WithRefTracking(true)) |
nothing calls this directly
no test coverage detected