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

Function test_named_simple_struct

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

Source from the content-addressed store, hash-verified

441#[test]
442#[ignore]
443fn test_named_simple_struct() {
444 let data_file_path = get_data_file();
445 let bytes = fs::read(&data_file_path).unwrap();
446 let mut fory = Fory::builder().compatible(true).xlang(true).build();
447 fory.register_by_name::<Color>("demo.color").unwrap();
448 fory.register_by_name::<Item>("demo.item").unwrap();
449 fory.register_by_name::<SimpleStruct>("demo.simple_struct")
450 .unwrap();
451
452 let local_obj = SimpleStruct {
453 f1: HashMap::from([(1, 1.0f64), (2, 2.0f64)]),
454 f2: 39,
455 f3: Item {
456 name: "item".to_string(),
457 },
458 f4: "f4".to_string(),
459 f5: Color::White,
460 f6: vec!["f6".to_string()],
461 f7: 40,
462 f8: 41,
463 last: 42,
464 };
465 let remote_obj: SimpleStruct = fory.deserialize(&bytes).unwrap();
466 assert_eq!(remote_obj, local_obj);
467 let new_bytes = fory.serialize(&remote_obj).unwrap();
468 let new_local_obj: SimpleStruct = fory.deserialize(&new_bytes).unwrap();
469 assert_eq!(new_local_obj, local_obj);
470 fs::write(&data_file_path, new_bytes).unwrap();
471}
472
473#[test]
474#[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