Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: tests/HashTest.cpp

Issue 1057043003: SkTHash: remove() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkTHash.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/HashTest.cpp
diff --git a/tests/HashTest.cpp b/tests/HashTest.cpp
index d2acafe08b04aef88c2b71d013a3ce0db0097c17..3327368995abdaac92ab2515cb5ea3b292393c46 100644
--- a/tests/HashTest.cpp
+++ b/tests/HashTest.cpp
@@ -52,6 +52,15 @@ DEF_TEST(HashMap, r) {
REPORTER_ASSERT(r, map.count() == N);
+ for (int i = 0; i < N/2; i++) {
+ map.remove(i);
+ }
+ for (int i = 0; i < N; i++) {
+ double* found = map.find(i);
+ REPORTER_ASSERT(r, (found == nullptr) == i < N/2);
joshualitt 2015/04/21 13:21:10 The compiler complained about the lack of parenthe
mtklein 2015/04/21 13:37:57 Where?
joshualitt 2015/04/21 13:40:31 == i < N/2 ../../tests/HashTest.cpp:60:53: error:
mtklein 2015/04/21 13:48:29 Done.
+ }
+ REPORTER_ASSERT(r, map.count() == N/2);
+
map.reset();
REPORTER_ASSERT(r, map.count() == 0);
}
@@ -71,6 +80,10 @@ DEF_TEST(HashSet, r) {
REPORTER_ASSERT(r, set.find(SkString("Hello")));
REPORTER_ASSERT(r, *set.find(SkString("Hello")) == SkString("Hello"));
+ set.remove(SkString("Hello"));
+ REPORTER_ASSERT(r, !set.contains(SkString("Hello")));
+ REPORTER_ASSERT(r, set.count() == 1);
+
set.reset();
REPORTER_ASSERT(r, set.count() == 0);
}
« no previous file with comments | « src/core/SkTHash.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698