Skip to content

Commit 66bf109

Browse files
committed
Add test for std::net::lookup_host() duplicates
1 parent 0314d17 commit 66bf109

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/libstd/sys/common/net.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,22 @@ impl fmt::Debug for UdpSocket {
601601
.finish()
602602
}
603603
}
604+
605+
#[cfg(test)]
606+
mod tests {
607+
use prelude::v1::*;
608+
609+
use super::*;
610+
use collections::HashMap;
611+
612+
#[test]
613+
fn no_lookup_host_duplicates() {
614+
let mut addrs = HashMap::new();
615+
let lh = match lookup_host("localhost") {
616+
Ok(lh) => lh,
617+
Err(e) => panic!("couldn't resolve `localhost': {}", e)
618+
};
619+
let _na = lh.map(|sa| *addrs.entry(sa).or_insert(0) += 1).count();
620+
assert!(addrs.values().filter(|&&v| v > 1).count() == 0);
621+
}
622+
}

0 commit comments

Comments
 (0)