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

Unified Diff: mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc

Issue 2715153004: Mojo: Support enums as map keys in WTF (Closed)
Patch Set: Qualify name of generated hash fn Created 3 years, 10 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
Index: mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc b/mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc
index 88b7a236791e651c0155b2a9184110b12e3a992e..766e690d9f99df48a87ef2c85f966fa642ae955d 100644
--- a/mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/wtf_hash_unittest.cc
@@ -5,7 +5,9 @@
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "mojo/public/interfaces/bindings/tests/test_structs.mojom-blink.h"
+#include "mojo/public/interfaces/bindings/tests/test_wtf_types.mojom-blink.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/wtf/HashFunctions.h"
namespace mojo {
namespace test {
@@ -43,6 +45,28 @@ TEST_F(WTFHashTest, UnmappedNativeStruct) {
blink::UnmappedNativeStruct::New()));
}
+TEST_F(WTFHashTest, Enum) {
+ // Just check that this template instantiation compiles.
+
+ // Top-level.
+ ASSERT_EQ(WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash(
+ blink::TopLevelEnum::E0),
+ WTF::DefaultHash<blink::TopLevelEnum>::Hash().hash(
+ blink::TopLevelEnum::E0));
+
+ // Nested in struct.
+ ASSERT_EQ(WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash(
+ blink::TestWTFStruct::NestedEnum::E0),
+ WTF::DefaultHash<blink::TestWTFStruct::NestedEnum>::Hash().hash(
+ blink::TestWTFStruct::NestedEnum::E0));
+
+ // Nested in interface.
+ ASSERT_EQ(WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash(
+ blink::TestWTF::NestedEnum::E0),
+ WTF::DefaultHash<blink::TestWTF::NestedEnum>::Hash().hash(
+ blink::TestWTF::NestedEnum::E0));
+}
+
} // namespace
} // namespace test
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698