summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util/tests/set/set_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/util/tests/set/set_test.cpp')
-rw-r--r--lib/mesa/src/util/tests/set/set_test.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/mesa/src/util/tests/set/set_test.cpp b/lib/mesa/src/util/tests/set/set_test.cpp
index 0b4355af1..67e3085ee 100644
--- a/lib/mesa/src/util/tests/set/set_test.cpp
+++ b/lib/mesa/src/util/tests/set/set_test.cpp
@@ -51,6 +51,27 @@ TEST(set, basic)
entry = _mesa_set_search(s, a);
EXPECT_FALSE(entry);
+ _mesa_set_clear(s, NULL);
+ EXPECT_EQ(s->entries, 0);
+ EXPECT_EQ(s->deleted_entries, 0);
+ set_foreach(s, he) {
+ GTEST_FAIL();
+ }
+
+ _mesa_set_add(s, a);
+ _mesa_set_add(s, b);
+ EXPECT_EQ(s->entries, 2);
+ unsigned count = s->entries;
+ set_foreach_remove(s, he) {
+ EXPECT_TRUE(he->key == a || he->key == b);
+ EXPECT_EQ(s->entries, count--);
+ EXPECT_EQ(s->deleted_entries, 0);
+ }
+ EXPECT_EQ(s->entries, 0);
+ set_foreach(s, he) {
+ GTEST_FAIL();
+ }
+
_mesa_set_destroy(s, NULL);
}
@@ -136,12 +157,16 @@ TEST(set, search_or_add)
_mesa_set_add(s, &b);
EXPECT_EQ(s->entries, 2);
- struct set_entry *entry = _mesa_set_search_or_add(s, &c);
+ bool found = false;
+ struct set_entry *entry = _mesa_set_search_or_add(s, &c, &found);
EXPECT_EQ(entry->key, (void *)&b);
+ EXPECT_EQ(found, true);
EXPECT_EQ(s->entries, 2);
- struct set_entry *entry3 = _mesa_set_search_or_add(s, &d);
+ found = false;
+ struct set_entry *entry3 = _mesa_set_search_or_add(s, &d, &found);
EXPECT_EQ(entry3->key, &d);
+ EXPECT_EQ(found, false);
EXPECT_EQ(s->entries, 3);
_mesa_set_destroy(s, NULL);