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

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

Issue 1683863002: Mojo C++ bindings: make mojo::Map<K,V> more friendly with std::map<K,V>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/map_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/map_unittest.cc b/mojo/public/cpp/bindings/tests/map_unittest.cc
index 444e0b375dfa74b1f524b04c6edf8483458fac70..65e68aed01e441a19420bb1887262499fbe2627a 100644
--- a/mojo/public/cpp/bindings/tests/map_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/map_unittest.cc
@@ -92,8 +92,8 @@ TEST_F(MapTest, TestIndexOperatorMoveOnly) {
for (size_t i = 0; i < kStringIntDataSize; ++i) {
auto it = map.find(kStringIntData[i].string_data);
ASSERT_TRUE(it != map.end());
- ASSERT_EQ(1u, it.GetValue().size());
- EXPECT_EQ(kStringIntData[i].int_data, it.GetValue()[0]);
+ ASSERT_EQ(1u, it->second.size());
+ EXPECT_EQ(kStringIntData[i].int_data, it->second[0]);
}
}
@@ -266,8 +266,8 @@ TEST_F(MapTest, MapArrayClone) {
Map<String, Array<String>> m2 = m.Clone();
for (auto it = m2.begin(); it != m2.end(); ++it) {
- ASSERT_EQ(1u, it.GetValue().size());
- EXPECT_EQ(it.GetKey(), it.GetValue().at(0));
+ ASSERT_EQ(1u, it->second.size());
+ EXPECT_EQ(it->first, it->second.at(0));
}
}
@@ -316,6 +316,41 @@ TEST_F(MapTest, ArrayOfMap) {
}
}
+TEST_F(MapTest, MoveFromAndToSTLMap_Copyable) {
+ std::map<int32_t, CopyableType> map1;
+ map1.insert(std::make_pair(123, CopyableType()));
+ map1[123].ResetCopied();
+
+ Map<int32_t, CopyableType> mojo_map(std::move(map1));
+ ASSERT_EQ(1u, mojo_map.size());
+ ASSERT_NE(mojo_map.end(), mojo_map.find(123));
+ ASSERT_FALSE(mojo_map[123].copied());
+
+ std::map<int32_t, CopyableType> map2(mojo_map.PassStorage());
+ ASSERT_EQ(1u, map2.size());
+ ASSERT_NE(map2.end(), map2.find(123));
+ ASSERT_FALSE(map2[123].copied());
+
+ ASSERT_EQ(0u, mojo_map.size());
+ ASSERT_TRUE(mojo_map.is_null());
+}
+
+TEST_F(MapTest, MoveFromAndToSTLMap_MoveOnly) {
+ std::map<int32_t, MoveOnlyType> map1;
+ map1.insert(std::make_pair(123, MoveOnlyType()));
+
+ Map<int32_t, MoveOnlyType> mojo_map(std::move(map1));
+ ASSERT_EQ(1u, mojo_map.size());
+ ASSERT_NE(mojo_map.end(), mojo_map.find(123));
+
+ std::map<int32_t, MoveOnlyType> map2(mojo_map.PassStorage());
+ ASSERT_EQ(1u, map2.size());
+ ASSERT_NE(map2.end(), map2.find(123));
+
+ ASSERT_EQ(0u, mojo_map.size());
+ ASSERT_TRUE(mojo_map.is_null());
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698