]> git.lizzy.rs Git - rust.git/commitdiff
Improve output if no_lookup_host_duplicates fails
authorPhilip Munksgaard <pmunksgaard@gmail.com>
Sat, 15 Sep 2018 09:50:41 +0000 (11:50 +0200)
committerPhilip Munksgaard <pmunksgaard@gmail.com>
Sat, 15 Sep 2018 15:17:35 +0000 (17:17 +0200)
If the test fails, output the offending addresses and a helpful error message.
Also slightly improve legibility of the preceding line that puts the addresses
into a HashMap.

src/libstd/sys_common/net.rs

index b841afe1a5141dfd2db749ad09077400c8cc1933..d09a233ed896f296529bbf597613a28285909639 100644 (file)
@@ -622,7 +622,8 @@ fn no_lookup_host_duplicates() {
             Ok(lh) => lh,
             Err(e) => panic!("couldn't resolve `localhost': {}", e)
         };
-        let _na = lh.map(|sa| *addrs.entry(sa).or_insert(0) += 1).count();
-        assert!(addrs.values().filter(|&&v| v > 1).count() == 0);
+        for sa in lh { *addrs.entry(sa).or_insert(0) += 1; };
+        assert_eq!(addrs.iter().filter(|&(_, &v)| v > 1).collect::<Vec<_>>(), vec![],
+                   "There should be no duplicate localhost entries");
     }
 }