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

Function test_compatible_to_empty_struct

rust/tests/tests/test_simple_struct.rs:123–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121// Test 4: Compatible mode - serialize with field, deserialize with empty struct
122#[test]
123fn test_compatible_to_empty_struct() {
124 #[derive(ForyStruct, Debug)]
125 struct DataWithField {
126 value: i32,
127 name: String,
128 }
129
130 #[derive(ForyStruct, Debug)]
131 struct EmptyData {}
132
133 let mut fory1 = Fory::builder().xlang(false).compatible(true).build();
134 let mut fory2 = Fory::builder().xlang(false).compatible(true).build();
135 fory1.register::<DataWithField>(101).unwrap();
136 fory2.register::<EmptyData>(101).unwrap();
137
138 let data1 = DataWithField {
139 value: 42,
140 name: String::from("test"),
141 };
142 let bytes = fory1.serialize(&data1).unwrap();
143 let _result: EmptyData = fory2.deserialize(&bytes).unwrap();
144 // If we get here without panic, the test passes
145}
146
147// Test 5: Compatible mode - empty struct to struct with fields (fields get defaults)
148#[test]

Callers

nothing calls this directly

Calls 6

serializeMethod · 0.65
deserializeMethod · 0.65
buildMethod · 0.45
compatibleMethod · 0.45
xlangMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected