From 4280d1e6c6d2a2f496f4ef187731863dc5ca0df7 Mon Sep 17 00:00:00 2001 From: Inga Date: Tue, 14 Nov 2023 01:42:23 +0000 Subject: [PATCH] more tests --- .../tests/ranged_number_allocator_tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hostnames_allocator/tests/ranged_number_allocator_tests.rs b/hostnames_allocator/tests/ranged_number_allocator_tests.rs index 200ca4a..a9045a8 100644 --- a/hostnames_allocator/tests/ranged_number_allocator_tests.rs +++ b/hostnames_allocator/tests/ranged_number_allocator_tests.rs @@ -96,6 +96,13 @@ fn allocate_combines_two_adjacent_ranges_starting_with_one() { check_allocator(allocator, &[(1, 15)]); } +#[test] +fn allocate_combines_two_adjacent_ranges_starting_with_one_extra() { + let mut allocator = create_allocator(&[(1, 5), (7, 15), (20, 30)]); + assert_eq!(allocator.allocate(), 6); + check_allocator(allocator, &[(1, 15), (20, 30)]); +} + #[test] fn allocate_adds_value_for_range_starting_with_two() { let mut allocator = create_allocator(&[(2, 10)]); @@ -103,6 +110,13 @@ fn allocate_adds_value_for_range_starting_with_two() { check_allocator(allocator, &[(1, 10)]); } +#[test] +fn allocate_adds_value_for_range_starting_with_two_extra() { + let mut allocator = create_allocator(&[(2, 10), (20, 30)]); + assert_eq!(allocator.allocate(), 1); + check_allocator(allocator, &[(1, 10), (20, 30)]); +} + #[test] fn allocate_adds_value_for_range_starting_with_ten() { let mut allocator = create_allocator(&[(10, 20)]);