diff options
author | Jason Merrill <jason@redhat.com> | 2019-03-14 18:47:01 -0400 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-14 23:47:01 +0100 |
commit | 62de703f1990d2c4dd7ee0c41bfa886b5c589793 (patch) | |
tree | 2a29bb29ec24c6fcd36a8c7374df0da26cd7134b /gcc/hash-set-tests.c | |
parent | 12fb7712a8a20fce6f3dac80251e67251c01c209 (diff) | |
download | gcc-62de703f1990d2c4dd7ee0c41bfa886b5c589793.zip gcc-62de703f1990d2c4dd7ee0c41bfa886b5c589793.tar.gz gcc-62de703f1990d2c4dd7ee0c41bfa886b5c589793.tar.bz2 |
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 <jakub@redhat.com>
From-SVN: r269695
Diffstat (limited to 'gcc/hash-set-tests.c')
-rw-r--r-- | gcc/hash-set-tests.c | 15 |
1 files changed, 15 insertions, 0 deletions
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. */ |