From 62de703f1990d2c4dd7ee0c41bfa886b5c589793 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 14 Mar 2019 18:47:01 -0400 Subject: hash-table.h (remove_elt_with_hash): Return if slot is NULL rather than if is_empty (*slot). * hash-table.h (remove_elt_with_hash): Return if slot is NULL rather than if is_empty (*slot). * hash-set-tests.c (test_set_of_strings): Add tests for addition of existing elt and for elt removal. * hash-map-tests.c (test_map_of_strings_to_int): Add test for removal of already removed elt. * hashtab.c (htab_remove_elt_with_hash): Return if slot is NULL rather than if *slot is HTAB_EMPTY_ENTRY. Co-Authored-By: Jakub Jelinek From-SVN: r269695 --- gcc/hash-set-tests.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/hash-set-tests.c') diff --git a/gcc/hash-set-tests.c b/gcc/hash-set-tests.c index 5ca1e4e..f75d41a 100644 --- a/gcc/hash-set-tests.c +++ b/gcc/hash-set-tests.c @@ -48,11 +48,26 @@ test_set_of_strings () ASSERT_EQ (false, s.add (red)); ASSERT_EQ (false, s.add (green)); ASSERT_EQ (false, s.add (blue)); + ASSERT_EQ (true, s.add (green)); /* Verify that the values are now within the set. */ ASSERT_EQ (true, s.contains (red)); ASSERT_EQ (true, s.contains (green)); ASSERT_EQ (true, s.contains (blue)); + ASSERT_EQ (3, s.elements ()); + + /* Test removal. */ + s.remove (red); + ASSERT_EQ (false, s.contains (red)); + ASSERT_EQ (true, s.contains (green)); + ASSERT_EQ (true, s.contains (blue)); + ASSERT_EQ (2, s.elements ()); + + s.remove (red); + ASSERT_EQ (false, s.contains (red)); + ASSERT_EQ (true, s.contains (green)); + ASSERT_EQ (true, s.contains (blue)); + ASSERT_EQ (2, s.elements ()); } /* Run all of the selftests within this file. */ -- cgit v1.1