Debian Codegraph @

debian/rust-vendor/litemap/tests/serde.rs

raw
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5 use litemap::LiteMap;
6
7 #[test]
8 fn test_ser() {
9 let mut map = LiteMap::new_vec();
10 map.insert(1, "jat");
11 map.insert(4, "sei");
12 map.insert(3, "saam");
13 map.insert(2, "ji");
14
15 let json_string = serde_json::to_string(&map).unwrap();
16
17 assert_eq!(json_string, r#"{"1":"jat","2":"ji","3":"saam","4":"sei"}"#);
18
19 let new_map = serde_json::from_str(&json_string).unwrap();
20
21 assert_eq!(map, new_map);
22 }