()
| 147 | // Test 5: Compatible mode - empty struct to struct with fields (fields get defaults) |
| 148 | #[test] |
| 149 | fn test_compatible_from_empty_struct() { |
| 150 | #[derive(ForyStruct, Debug)] |
| 151 | struct EmptyData {} |
| 152 | |
| 153 | #[derive(ForyStruct, Debug)] |
| 154 | struct DataWithField { |
| 155 | value: i32, |
| 156 | name: String, |
| 157 | } |
| 158 | |
| 159 | let mut fory1 = Fory::builder().xlang(false).compatible(true).build(); |
| 160 | let mut fory2 = Fory::builder().xlang(false).compatible(true).build(); |
| 161 | fory1.register::<EmptyData>(102).unwrap(); |
| 162 | fory2.register::<DataWithField>(102).unwrap(); |
| 163 | |
| 164 | let data1 = EmptyData {}; |
| 165 | let bytes = fory1.serialize(&data1).unwrap(); |
| 166 | let result: DataWithField = fory2.deserialize(&bytes).unwrap(); |
| 167 | assert_eq!(result.value, 0); // Default for i32 |
| 168 | assert_eq!(result.name, String::default()); // Default for String |
| 169 | } |
| 170 | |
| 171 | #[test] |
| 172 | fn test_compatible_vec_to_empty_struct() { |
nothing calls this directly
no test coverage detected