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

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

Issue 1387993002: mojo::Serialize*_() calls now propogate/return validation errors. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: unscope VALIDATION_ERROR_* enum values. early exit on null-input. additional comments Created 5 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
Index: mojo/public/cpp/bindings/tests/union_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/union_unittest.cc b/mojo/public/cpp/bindings/tests/union_unittest.cc
index 261b0ee43b63b152a59bfab35b03ce5f801d142c..586c0e451182559001564a5f7f23e72588e0cb44 100644
--- a/mojo/public/cpp/bindings/tests/union_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/union_unittest.cc
@@ -493,7 +493,8 @@ TEST(UnionTest, Serialization_UnionOfPods) {
mojo::internal::FixedBufferForTesting buf(size);
viettrungluu 2015/10/09 01:35:20 mojo::
vardhan 2015/10/09 22:31:29 (See comments regarding this in other files)
internal::SmallStruct_Data* data = nullptr;
viettrungluu 2015/10/09 01:35:20 No mojo:: kill me now
vardhan 2015/10/09 22:31:29 :-) (this |internal| is a referring to the |inter
- Serialize_(small_struct.get(), &buf, &data);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ Serialize_(small_struct.get(), &buf, &data));
SmallStructPtr deserialized(SmallStruct::New());
Deserialize_(data, deserialized.get());
@@ -513,7 +514,8 @@ TEST(UnionTest, Serialization_UnionOfObjects) {
mojo::internal::FixedBufferForTesting buf(size);
internal::SmallObjStruct_Data* data = nullptr;
- Serialize_(obj_struct.get(), &buf, &data);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ Serialize_(obj_struct.get(), &buf, &data));
std::vector<Handle> handles;
data->EncodePointersAndHandles(&handles);
@@ -536,7 +538,8 @@ TEST(UnionTest, Validation_UnionsInStruct) {
mojo::internal::FixedBufferForTesting buf(size);
internal::SmallStruct_Data* data = nullptr;
- Serialize_(small_struct.get(), &buf, &data);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ Serialize_(small_struct.get(), &buf, &data));
void* raw_buf = buf.Leak();
mojo::internal::BoundsChecker bounds_checker(data,
@@ -556,7 +559,8 @@ TEST(UnionTest, Validation_PodUnionInStruct_Failure) {
mojo::internal::FixedBufferForTesting buf(size);
internal::SmallStruct_Data* data = nullptr;
- Serialize_(small_struct.get(), &buf, &data);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ Serialize_(small_struct.get(), &buf, &data));
data->pod_union.tag = static_cast<internal::PodUnion_Data::PodUnion_Tag>(100);
void* raw_buf = buf.Leak();
@@ -595,7 +599,8 @@ TEST(UnionTest, Validation_NullableUnion) {
mojo::internal::FixedBufferForTesting buf(size);
internal::SmallStruct_Data* data = nullptr;
- Serialize_(small_struct.get(), &buf, &data);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ Serialize_(small_struct.get(), &buf, &data));
void* raw_buf = buf.Leak();
mojo::internal::BoundsChecker bounds_checker(data,
@@ -635,7 +640,8 @@ TEST(UnionTest, PodUnionInMapSerialization) {
mojo::internal::Map_Data<mojo::internal::String_Data*,
internal::PodUnion_Data>* data;
mojo::internal::ArrayValidateParams validate_params(0, false, nullptr);
- SerializeMap_(&map, &buf, &data, &validate_params);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ SerializeMap_(&map, &buf, &data, &validate_params));
Map<String, PodUnionPtr> map2;
Deserialize_(data, &map2);
@@ -659,7 +665,8 @@ TEST(UnionTest, PodUnionInMapSerializationWithNull) {
mojo::internal::Map_Data<mojo::internal::String_Data*,
internal::PodUnion_Data>* data;
mojo::internal::ArrayValidateParams validate_params(0, true, nullptr);
- SerializeMap_(&map, &buf, &data, &validate_params);
+ EXPECT_EQ(mojo::internal::VALIDATION_ERROR_NONE,
+ SerializeMap_(&map, &buf, &data, &validate_params));
Map<String, PodUnionPtr> map2;
Deserialize_(data, &map2);

Powered by Google App Engine
This is Rietveld 408576698