You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rust-puzzles/hostnames_allocator/tests/hostnames_allocator.rs

19 lines
783 B

extern crate hostnames_allocator;
use hostnames_allocator::hostnames_allocator::HostnamesAllocator;
#[test]
fn allocator_allocates_hostnames() {
let mut allocator = HostnamesAllocator::new();
assert_eq!(allocator.allocate("gateway"), "gateway1");
assert_eq!(allocator.allocate("gateway"), "gateway2");
assert_eq!(allocator.allocate("gateway"), "gateway3");
assert_eq!(allocator.allocate("proxy"), "proxy1");
assert_eq!(allocator.allocate("proxy"), "proxy2");
allocator.free("gateway2");
allocator.free("gateway5");
assert_eq!(allocator.allocate("proxy"), "proxy3");
assert_eq!(allocator.allocate("gateway"), "gateway2");
assert_eq!(allocator.allocate("gateway"), "gateway4");
assert_eq!(allocator.allocate("gateway"), "gateway5");
}