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

Function test_struct_with_map

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

Source from the content-addressed store, hash-verified

1056#[test]
1057#[ignore]
1058fn test_struct_with_map() {
1059 let data_file_path = get_data_file();
1060 let bytes = fs::read(&data_file_path).unwrap();
1061
1062 let mut fory = Fory::builder().compatible(true).xlang(true).build();
1063 fory.register::<StructWithMap>(202).unwrap();
1064 let mut reader = Reader::new(bytes.as_slice());
1065
1066 let struct1 = StructWithMap {
1067 data: HashMap::from([
1068 (Some("key1".to_string()), Some("value1".to_string())),
1069 (Some("key2".to_string()), Some("value2".to_string())),
1070 ]),
1071 };
1072 let struct2 = StructWithMap {
1073 data: HashMap::from([
1074 (Some("k1".to_string()), None),
1075 (None, Some("v2".to_string())),
1076 ]),
1077 };
1078
1079 let remote_struct1: StructWithMap = fory.deserialize_from(&mut reader).unwrap();
1080 assert_eq!(remote_struct1, struct1);
1081 let remote_struct2: StructWithMap = fory.deserialize_from(&mut reader).unwrap();
1082 assert_eq!(remote_struct2, struct2);
1083
1084 let mut buf = Vec::new();
1085 fory.serialize_to(&mut buf, &remote_struct1).unwrap();
1086 fory.serialize_to(&mut buf, &remote_struct2).unwrap();
1087 fs::write(&data_file_path, buf).unwrap();
1088}
1089
1090#[test]
1091#[ignore]

Callers

nothing calls this directly

Calls 11

SomeFunction · 0.85
deserialize_fromMethod · 0.80
get_data_fileFunction · 0.70
readFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
buildMethod · 0.45
xlangMethod · 0.45
compatibleMethod · 0.45
to_stringMethod · 0.45
serialize_toMethod · 0.45

Tested by

no test coverage detected