From e9e799f7506a620bcebd291d716e895faa9d427b Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 26 May 2014 15:20:39 -0700 Subject: [PATCH] collections: add Show impl test for HashMap --- src/libcollections/hashmap.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs index 1b79b84ff908..c51061067dc1 100644 --- a/src/libcollections/hashmap.rs +++ b/src/libcollections/hashmap.rs @@ -2003,6 +2003,20 @@ mod test_map { assert_eq!(m1, m2); } + #[test] + fn test_show() { + let mut map: HashMap = HashMap::new(); + let empty: HashMap = HashMap::new(); + + map.insert(1, 2); + map.insert(3, 4); + + let map_str = format!("{}", map); + + assert!(map_str == "{1: 2, 3: 4}".to_owned() || map_str == "{3: 4, 1: 2}".to_owned()); + assert_eq!(format!("{}", empty), "{}".to_owned()); + } + #[test] fn test_expand() { let mut m = HashMap::new();