From 4f3c9003d53b458d7c12d4682a2a51bae814f403 Mon Sep 17 00:00:00 2001 From: Davi Reis Date: Fri, 15 Jun 2012 18:09:54 -0300 Subject: [PATCH] A couple test cases. --- cxxmph/dense_hash_map_test.cc | 2 ++ cxxmph/map_tester.h | 15 +++++++++++++++ cxxmph/mph_map_test.cc | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cxxmph/dense_hash_map_test.cc b/cxxmph/dense_hash_map_test.cc index 0c69b78..5f35e27 100644 --- a/cxxmph/dense_hash_map_test.cc +++ b/cxxmph/dense_hash_map_test.cc @@ -11,6 +11,8 @@ using namespace cxxmph; typedef MapTester Tester; +CXXMPH_CXX_TEST_CASE(empty_find, Tester::empty_find); +CXXMPH_CXX_TEST_CASE(empty_erase, Tester::empty_erase); CXXMPH_CXX_TEST_CASE(small_insert, Tester::small_insert); CXXMPH_CXX_TEST_CASE(large_insert, Tester::large_insert); CXXMPH_CXX_TEST_CASE(small_search, Tester::small_search); diff --git a/cxxmph/map_tester.h b/cxxmph/map_tester.h index 10d4357..e71ad6a 100644 --- a/cxxmph/map_tester.h +++ b/cxxmph/map_tester.h @@ -17,6 +17,21 @@ using namespace std; template class map_type> struct MapTester { + static bool empty_find() { + map_type m; + for (int i = 0; i < 1000; ++i) { + if (m.find(i) != m.end()) return false; + } + return true; + } + static bool empty_erase() { + map_type m; + for (int i = 0; i < 1000; ++i) { + m.erase(i); + if (m.size()) return false; + } + return true; + } static bool small_insert() { map_type m; // Start counting from 1 to not touch default constructed value bugs diff --git a/cxxmph/mph_map_test.cc b/cxxmph/mph_map_test.cc index 5fb73ea..26f70e1 100644 --- a/cxxmph/mph_map_test.cc +++ b/cxxmph/mph_map_test.cc @@ -11,7 +11,8 @@ using namespace cxxmph; typedef MapTester Tester; -/* +CXXMPH_CXX_TEST_CASE(empty_find, Tester::empty_find); +CXXMPH_CXX_TEST_CASE(empty_erase, Tester::empty_erase); CXXMPH_CXX_TEST_CASE(small_insert, Tester::small_insert); CXXMPH_CXX_TEST_CASE(large_insert, Tester::large_insert); CXXMPH_CXX_TEST_CASE(small_search, Tester::small_search); @@ -21,5 +22,4 @@ CXXMPH_CXX_TEST_CASE(string_search, Tester::string_search); CXXMPH_CXX_TEST_CASE(rehash_zero, Tester::rehash_zero); CXXMPH_CXX_TEST_CASE(rehash_size, Tester::rehash_size); CXXMPH_CXX_TEST_CASE(erase_value, Tester::erase_value); -*/ CXXMPH_CXX_TEST_CASE(erase_iterator, Tester::erase_iterator);