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

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

Issue 1811413002: [Extensions] Update generated code to support move operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix 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') | tools/json_schema_compiler/util.h » ('j') | 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 5e28386579d9952c6f5b0410c307dae71819fad9..2cb6fc62c4a7016575371965d83e180633a8073f 100644
--- a/tools/json_schema_compiler/test/objects_unittest.cc
+++ b/tools/json_schema_compiler/test/objects_unittest.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "tools/json_schema_compiler/test/objects.h"
-
#include <stddef.h>
#include "base/json/json_writer.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "tools/json_schema_compiler/test/objects.h"
+#include "tools/json_schema_compiler/test/objects_movable.h"
using namespace test::api::objects;
+using namespace test::api::objects_movable;
TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
{
@@ -71,3 +72,38 @@ TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) {
ASSERT_TRUE(results->GetDictionary(0, &result));
ASSERT_TRUE(result->Equals(&expected));
}
+TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) {
+ std::vector<MovablePod> pods;
+ {
+ MovablePod pod;
+ pod.foo = FOO_BAR;
+ pod.str = "str1";
+ pod.num = 42;
+ pod.b = true;
+ pods.push_back(std::move(pod));
+ }
+ {
+ MovablePod pod;
+ pod.foo = FOO_BAZ;
+ pod.str = "str2";
+ pod.num = 45;
+ pod.b = false;
+ pods.push_back(std::move(pod));
+ }
+ MovableParent parent;
+ parent.pods = std::move(pods);
+ parent.strs.push_back("pstr");
+
+ MovableParent parent2(std::move(parent));
+ ASSERT_EQ(2u, parent2.pods.size());
+ EXPECT_EQ(FOO_BAR, parent2.pods[0].foo);
+ EXPECT_EQ("str1", parent2.pods[0].str);
+ EXPECT_EQ(42, parent2.pods[0].num);
+ EXPECT_TRUE(parent2.pods[0].b);
+ EXPECT_EQ(FOO_BAZ, parent2.pods[1].foo);
+ EXPECT_EQ("str2", parent2.pods[1].str);
+ EXPECT_EQ(45, parent2.pods[1].num);
+ EXPECT_FALSE(parent2.pods[1].b);
+ ASSERT_EQ(1u, parent2.strs.size());
+ EXPECT_EQ("pstr", parent2.strs[0]);
+}
« no previous file with comments | « tools/json_schema_compiler/test/objects_movable.idl ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698