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

Function test_simple_struct

rust/tests/tests/test_cross_language.rs:412–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

410#[test]
411#[ignore]
412fn test_simple_struct() {
413 let data_file_path = get_data_file();
414 let bytes = fs::read(&data_file_path).unwrap();
415 let mut fory = Fory::builder().compatible(true).xlang(true).build();
416 fory.register::<Color>(101).unwrap();
417 fory.register::<Item>(102).unwrap();
418 fory.register::<SimpleStruct>(103).unwrap();
419
420 let local_obj = SimpleStruct {
421 f1: HashMap::from([(1, 1.0f64), (2, 2.0f64)]),
422 f2: 39,
423 f3: Item {
424 name: "item".to_string(),
425 },
426 f4: "f4".to_string(),
427 f5: Color::White,
428 f6: vec!["f6".to_string()],
429 f7: 40,
430 f8: 41,
431 last: 42,
432 };
433 let remote_obj: SimpleStruct = fory.deserialize(&bytes).unwrap();
434 assert_eq!(remote_obj, local_obj);
435 let new_bytes = fory.serialize(&remote_obj).unwrap();
436 let new_local_obj: SimpleStruct = fory.deserialize(&new_bytes).unwrap();
437 assert_eq!(new_local_obj, local_obj);
438 fs::write(&data_file_path, new_bytes).unwrap();
439}
440
441#[test]
442#[ignore]

Callers

nothing calls this directly

Calls 10

get_data_fileFunction · 0.70
deserializeMethod · 0.65
serializeMethod · 0.65
readFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
buildMethod · 0.45
xlangMethod · 0.45
compatibleMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected