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

Function test_list

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

Source from the content-addressed store, hash-verified

506#[test]
507#[ignore]
508fn test_list() {
509 let data_file_path = get_data_file();
510 let bytes = fs::read(&data_file_path).unwrap();
511
512 let mut fory = Fory::builder().compatible(true).xlang(true).build();
513 fory.register::<Item>(102).unwrap();
514 let mut reader = Reader::new(bytes.as_slice());
515
516 let str_list = vec![Some("a".to_string()), Some("b".to_string())];
517 let str_list2 = vec![None, Some("b".to_string())];
518 let item = Item {
519 name: "a".to_string(),
520 };
521 let item2 = Item {
522 name: "b".to_string(),
523 };
524 let item3 = Item {
525 name: "c".to_string(),
526 };
527 let item_list = vec![Some(item), Some(item2)];
528 let item_list2 = vec![None, Some(item3)];
529
530 let remote_str_list: Vec<Option<String>> = fory.deserialize_from(&mut reader).unwrap();
531 assert_eq!(remote_str_list, str_list);
532 let remote_str_list2: Vec<Option<String>> = fory.deserialize_from(&mut reader).unwrap();
533 assert_eq!(remote_str_list2, str_list2);
534 let remote_item_list: Vec<Option<Item>> = fory.deserialize_from(&mut reader).unwrap();
535 assert_eq!(remote_item_list, item_list);
536 let remote_item_list2: Vec<Option<Item>> = fory.deserialize_from(&mut reader).unwrap();
537 assert_eq!(remote_item_list2, item_list2);
538
539 let mut buf = Vec::new();
540 fory.serialize_to(&mut buf, &remote_str_list).unwrap();
541 fory.serialize_to(&mut buf, &remote_str_list2).unwrap();
542 fory.serialize_to(&mut buf, &remote_item_list).unwrap();
543 fory.serialize_to(&mut buf, &remote_item_list2).unwrap();
544
545 fs::write(&data_file_path, buf).unwrap();
546}
547
548#[test]
549#[ignore]

Callers

nothing calls this directly

Calls 10

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