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

Function test_string_serializer

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

Source from the content-addressed store, hash-verified

279#[test]
280#[ignore]
281fn test_string_serializer() {
282 let data_file_path = get_data_file();
283 let bytes = fs::read(&data_file_path).unwrap();
284 let mut reader = Reader::new(bytes.as_slice());
285 let fory = Fory::builder()
286 .compatible(true)
287 .xlang(true)
288 .compress_string(false)
289 .build();
290 let mut reader_compress = Reader::new(bytes.as_slice());
291 let fory_compress = Fory::builder()
292 .compatible(true)
293 .xlang(true)
294 .compress_string(true)
295 .build();
296 let test_strings: Vec<String> = vec![
297 // Latin1
298 "ab".to_string(),
299 "Rust123".to_string(),
300 "Çüéâäàåçêëèïî".to_string(),
301 // UTF16
302 "こんにちは".to_string(),
303 "Привет".to_string(),
304 "𝄞🎵🎶".to_string(),
305 // UTF8
306 "Hello, 世界".to_string(),
307 ];
308 for s in &test_strings {
309 assert_eq!(*s, fory.deserialize_from::<String>(&mut reader).unwrap());
310 assert_eq!(
311 *s,
312 fory_compress
313 .deserialize_from::<String>(&mut reader_compress)
314 .unwrap()
315 );
316 }
317 let fory = Fory::builder().compatible(true).xlang(true).build();
318 let mut buf = Vec::new();
319 for s in &test_strings {
320 fory.serialize_to(&mut buf, s).unwrap();
321 }
322 fs::write(&data_file_path, buf).unwrap();
323}
324
325macro_rules! assert_de {
326 ($fory:expr, $reader:expr, $ty:ty, $expected:expr) => {{

Callers

nothing calls this directly

Calls 9

compress_stringMethod · 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
serialize_toMethod · 0.45

Tested by

no test coverage detected