diff --git a/tests/custom_allocator_tests.cpp b/tests/custom_allocator_tests.cpp index 1cef3c1..a8ebc28 100644 --- a/tests/custom_allocator_tests.cpp +++ b/tests/custom_allocator_tests.cpp @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(test_custom_allocator_1) { tsl::ordered_map, std::equal_to, custom_allocator>> map; - const int nb_elements = 10000; + const int nb_elements = 1000; for(int i = 0; i < nb_elements; i++) { map.insert({i, i*2}); } diff --git a/tests/ordered_map_tests.cpp b/tests/ordered_map_tests.cpp index 82a096f..1766495 100644 --- a/tests/ordered_map_tests.cpp +++ b/tests/ordered_map_tests.cpp @@ -922,6 +922,16 @@ BOOST_AUTO_TEST_CASE(test_move_constructor) { BOOST_CHECK(map_move == utils::get_filled_hash_map(nb_values*2)); } +BOOST_AUTO_TEST_CASE(test_move_constructor_empty) { + tsl::ordered_map map(0); + tsl::ordered_map map_move(std::move(map)); + + BOOST_CHECK(map.empty()); + BOOST_CHECK(map_move.empty()); + + BOOST_CHECK(map.find("") == map.end()); + BOOST_CHECK(map_move.find("") == map_move.end()); +} BOOST_AUTO_TEST_CASE(test_move_operator) { // insert x values in map, move map into map_move, check map and map_move, @@ -946,6 +956,18 @@ BOOST_AUTO_TEST_CASE(test_move_operator) { BOOST_CHECK(map_move == utils::get_filled_hash_map(nb_values*2)); } +BOOST_AUTO_TEST_CASE(test_move_operator_empty) { + tsl::ordered_map map(0); + tsl::ordered_map map_move; + map_move = (std::move(map)); + + BOOST_CHECK(map.empty()); + BOOST_CHECK(map_move.empty()); + + BOOST_CHECK(map.find("") == map.end()); + BOOST_CHECK(map_move.find("") == map_move.end()); +} + BOOST_AUTO_TEST_CASE(test_reassign_moved_object_move_constructor) { using HMap = tsl::ordered_map; @@ -1110,6 +1132,23 @@ BOOST_AUTO_TEST_CASE(test_swap) { BOOST_CHECK(map2 == (tsl::ordered_map{{1, 10}, {8, 80}, {3, 30}, {4, 40}})); } +BOOST_AUTO_TEST_CASE(test_swap_empty) { + tsl::ordered_map map = {{1, 10}, {8, 80}, {3, 30}}; + tsl::ordered_map map2; + + using std::swap; + swap(map, map2); + + BOOST_CHECK(map == (tsl::ordered_map{})); + BOOST_CHECK(map2 == (tsl::ordered_map{{1, 10}, {8, 80}, {3, 30}})); + + map.insert({6, 60}); + map2.insert({4, 40}); + + BOOST_CHECK(map == (tsl::ordered_map{{6, 60}})); + BOOST_CHECK(map2 == (tsl::ordered_map{{1, 10}, {8, 80}, {3, 30}, {4, 40}})); +} + /** * front(), back() */