Skip to content

Commit e9e799f

Browse files
committed
collections: add Show impl test for HashMap
1 parent 85d9cfb commit e9e799f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libcollections/hashmap.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,20 @@ mod test_map {
20032003
assert_eq!(m1, m2);
20042004
}
20052005

2006+
#[test]
2007+
fn test_show() {
2008+
let mut map: HashMap<int, int> = HashMap::new();
2009+
let empty: HashMap<int, int> = HashMap::new();
2010+
2011+
map.insert(1, 2);
2012+
map.insert(3, 4);
2013+
2014+
let map_str = format!("{}", map);
2015+
2016+
assert!(map_str == "{1: 2, 3: 4}".to_owned() || map_str == "{3: 4, 1: 2}".to_owned());
2017+
assert_eq!(format!("{}", empty), "{}".to_owned());
2018+
}
2019+
20062020
#[test]
20072021
fn test_expand() {
20082022
let mut m = HashMap::new();

0 commit comments

Comments
 (0)