| 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 | } |