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

Unified Diff: tools/json_schema_compiler/test/objects_unittest.cc

Issue 1837293004: [Extensions] Support choices in autogenerated movable types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar tests Created 4 years, 9 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 | « tools/json_schema_compiler/test/objects_movable.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/test/objects_unittest.cc
diff --git a/tools/json_schema_compiler/test/objects_unittest.cc b/tools/json_schema_compiler/test/objects_unittest.cc
index cd08793532364e7ef42132c6d1902b9872d01c6c..5c00926b69ea9f089b5e75a76c0692fd37d20185 100644
--- a/tools/json_schema_compiler/test/objects_unittest.cc
+++ b/tools/json_schema_compiler/test/objects_unittest.cc
@@ -96,6 +96,7 @@ TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) {
parent.pods = std::move(pods);
parent.strs.push_back("pstr");
parent.blob.additional_properties.SetString("key", "val");
+ parent.choice.as_string.reset(new std::string("string"));
MovableParent parent2(std::move(parent));
ASSERT_EQ(2u, parent2.pods.size());
@@ -109,11 +110,35 @@ TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) {
EXPECT_FALSE(parent2.pods[1].b);
ASSERT_EQ(1u, parent2.strs.size());
EXPECT_EQ("pstr", parent2.strs[0]);
+ EXPECT_FALSE(parent2.choice.as_movable_pod.get());
+ ASSERT_TRUE(parent2.choice.as_string.get());
+ EXPECT_EQ("string", *parent2.choice.as_string);
std::string blob_string;
EXPECT_TRUE(
parent2.blob.additional_properties.GetString("key", &blob_string));
EXPECT_EQ("val", blob_string);
+ {
+ MovableParent parent_with_pod_choice;
+ MovablePod pod;
+ pod.foo = FOO_BAZ;
+ pod.str = "str";
+ pod.num = 10;
+ pod.b = false;
+ parent_with_pod_choice.choice.as_movable_pod.reset(
+ new MovablePod(std::move(pod)));
+ parent2 = std::move(parent_with_pod_choice);
+ }
+ EXPECT_TRUE(parent2.pods.empty());
+ EXPECT_TRUE(parent2.strs.empty());
+ EXPECT_TRUE(parent2.blob.additional_properties.empty());
+ EXPECT_FALSE(parent2.choice.as_string.get());
+ ASSERT_TRUE(parent2.choice.as_movable_pod.get());
+ EXPECT_EQ(FOO_BAZ, parent2.choice.as_movable_pod->foo);
+ EXPECT_EQ("str", parent2.choice.as_movable_pod->str);
+ EXPECT_EQ(10, parent2.choice.as_movable_pod->num);
+ EXPECT_FALSE(parent2.choice.as_movable_pod->b);
+
MovableWithAdditional with_additional;
with_additional.str = "str";
std::vector<std::string> vals1;
« no previous file with comments | « tools/json_schema_compiler/test/objects_movable.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698