MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / test_nested_roundtrip

Function test_nested_roundtrip

tests/runtime/map/runner.rs:128–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126}
127
128fn test_nested_roundtrip() {
129 let mut inner_a = wit_bindgen::rt::Map::new();
130 inner_a.insert(1, "one".to_string());
131 inner_a.insert(2, "two".to_string());
132 let mut inner_b = wit_bindgen::rt::Map::new();
133 inner_b.insert(10, "ten".to_string());
134 let mut outer = wit_bindgen::rt::Map::new();
135 outer.insert("group-a".to_string(), inner_a);
136 outer.insert("group-b".to_string(), inner_b);
137 let result = nested_roundtrip(&outer);
138 assert_eq!(result.len(), 2);
139 let ra = result.get("group-a").unwrap();
140 assert_eq!(ra.get(&1).map(String::as_str), Some("one"));
141 assert_eq!(ra.get(&2).map(String::as_str), Some("two"));
142 let rb = result.get("group-b").unwrap();
143 assert_eq!(rb.get(&10).map(String::as_str), Some("ten"));
144}
145
146fn test_variant_roundtrip() {
147 let mut map = NamesById::new();

Callers 1

runMethod · 0.70

Calls 4

newFunction · 0.85
insertMethod · 0.45
to_stringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected