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

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

Issue 632603002: Mojo C++ bindings: support Arrays that contain Maps. Base URL: https://chromium.googlesource.com/chromium/src.git@4_mojo_map
Patch Set: Created 6 years, 2 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/lib/map_serialization.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 c621522134acf2f9c01083f62ae0dac1ef5f9edb..eddbe96bf502470728fcfa6d4886fd98e5286084 100644
--- a/mojo/public/cpp/bindings/tests/map_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/map_unittest.cc
@@ -5,6 +5,7 @@
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/lib/array_serialization.h"
#include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
+#include "mojo/public/cpp/bindings/lib/map_serialization.h"
#include "mojo/public/cpp/bindings/map.h"
#include "mojo/public/cpp/bindings/string.h"
#include "mojo/public/cpp/environment/environment.h"
@@ -250,6 +251,58 @@ TEST_F(MapTest, MapArrayClone) {
}
}
+TEST_F(MapTest, ArrayOfMap) {
+ {
+ Array<Map<int32_t, int8_t>> array(1);
+ array[0].insert(1, 42);
+
+ size_t size = GetSerializedSize_(array);
+
+ internal::FixedBuffer buf(size);
+ internal::Array_Data<internal::MapPointerPair<int32_t, int8_t>>* data;
+ SerializeArray_<
+ internal::ArrayValidateParams<0, false,
+ internal::ArrayValidateParams<0, false,
+ internal::NoValidateParams>>>(array.Pass(), &buf, &data);
+
+ Array<Map<int32_t, int8_t>> array2;
+ Deserialize_(data, &array2);
+ ASSERT_EQ(1u, array2.size());
+ ASSERT_EQ(1u, array2[0].size());
+ ASSERT_EQ(42, array2[0].at(1));
+ }
+
+ {
+ Array<Map<String, Array<bool>>> array(1);
+ Array<bool> map_value(2);
+ map_value[0] = false;
+ map_value[1] = true;
+
+ array[0].insert("hello world", map_value.Pass());
+
+ size_t size = GetSerializedSize_(array);
+
+ internal::FixedBuffer buf(size);
+ internal::Array_Data<
+ internal::MapPointerPair<internal::String_Data*,
+ internal::Array_Data<bool>*>>* data;
+ SerializeArray_<
+ internal::ArrayValidateParams<0, false,
+ internal::ArrayValidateParams<0, false,
+ internal::ArrayValidateParams<0, false,
+ internal::NoValidateParams>>>>(array.Pass(), &buf, &data);
+
+ Array<Map<String, Array<bool>>> array2;
+ Deserialize_(data, &array2);
+ ASSERT_EQ(1u, array2.size());
+ ASSERT_EQ(1u, array2[0].size());
+ ASSERT_FALSE(array2[0].at("hello world")[0]);
+ ASSERT_TRUE(array2[0].at("hello world")[1]);
+ }
+
+ // TODO(yzshen): More tests...
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_serialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698