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

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

Issue 659313006: mojo: Fix c++ bindings so serialization of empty arrays doesn't crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
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/array_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/array_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/array_unittest.cc b/mojo/public/cpp/bindings/tests/array_unittest.cc
index 133fa8b32436c455b6bc8a6d779bc2d36b8a9b11..0b083c72088d0e77c346cdf0ad2caf71f418fd30 100644
--- a/mojo/public/cpp/bindings/tests/array_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/array_unittest.cc
@@ -171,6 +171,21 @@ TEST_F(ArrayTest, Serialization_ArrayOfPOD) {
EXPECT_EQ(static_cast<int32_t>(i), array2[i]);
}
+TEST_F(ArrayTest, Serialization_EmptyArrayOfPOD) {
+ Array<int32_t> array(0);
+ size_t size = GetSerializedSize_(array);
+ EXPECT_EQ(8U, size);
+
+ FixedBuffer buf(size);
+ Array_Data<int32_t>* data;
+ SerializeArray_<ArrayValidateParams<0, false, NoValidateParams>>(
+ array.Pass(), &buf, &data);
+
+ Array<int32_t> array2;
+ Deserialize_(data, &array2);
+ EXPECT_EQ(0U, array2.size());
+}
+
TEST_F(ArrayTest, Serialization_ArrayOfArrayOfPOD) {
Array<Array<int32_t>> array(2);
for (size_t j = 0; j < array.size(); ++j) {
« no previous file with comments | « mojo/public/cpp/bindings/lib/array_serialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698