aboutsummaryrefslogtreecommitdiff
path: root/gcc/hash-map-tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/hash-map-tests.c')
-rw-r--r--gcc/hash-map-tests.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/hash-map-tests.c b/gcc/hash-map-tests.c
index 743fb26..63574029 100644
--- a/gcc/hash-map-tests.c
+++ b/gcc/hash-map-tests.c
@@ -280,6 +280,27 @@ test_map_of_type_with_ctor_and_dtor ()
}
}
+/* Test calling empty on a hash_map that has a key type with non-zero
+ "empty" value. */
+
+static void
+test_nonzero_empty_key ()
+{
+ typedef int_hash<int, INT_MIN, INT_MAX> IntHash;
+ hash_map<int, int, simple_hashmap_traits<IntHash, int> > x;
+
+ for (int i = 1; i != 32; ++i)
+ x.put (i, i);
+
+ ASSERT_EQ (x.get (0), NULL);
+ ASSERT_EQ (*x.get (1), 1);
+
+ x.empty ();
+
+ ASSERT_EQ (x.get (0), NULL);
+ ASSERT_EQ (x.get (1), NULL);
+}
+
/* Run all of the selftests within this file. */
void
@@ -288,6 +309,7 @@ hash_map_tests_c_tests ()
test_map_of_strings_to_int ();
test_map_of_int_to_strings ();
test_map_of_type_with_ctor_and_dtor ();
+ test_nonzero_empty_key ();
}
} // namespace selftest