MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / test_basis

Function test_basis

flow-message/src/cross/cow_map.rs:42–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41 #[test]
42 fn test_basis() {
43 let mut map = CowMap::new();
44 map.xset("a".to_owned(), 1i64);
45 map.xset("b".to_owned(), 1f64);
46 let mut sub = CowMap::new();
47 sub.xset("d".to_owned(), false);
48 map.xset("c".to_owned(), sub);
49
50 assert_eq!(map.xget("b"), Some(1f64));
51 let has_c: Option<&mut CowMap> = map.xget_mut("c");
52 assert!(has_c.is_some());
53 let sub = has_c.unwrap();
54 assert_eq!(sub.xget("d"), Some(false));
55 sub.xset("e".to_owned(), true);
56
57 let has_c: Option<&CowMap> = map.xget_ref("c");
58 assert!(has_c.is_some());
59 let sub = has_c.unwrap();
60 assert_eq!(sub.xget("e"), Some(true));
61 }
62}

Callers

nothing calls this directly

Calls 3

xget_mutMethod · 0.80
xsetMethod · 0.45
xget_refMethod · 0.45

Tested by

no test coverage detected