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

Unified Diff: base/values_unittest.cc

Issue 2843783003: Expose Value::GetList and Value(ListStorage) on ListValue (Closed)
Patch Set: Created 3 years, 8 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 | « base/values.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values_unittest.cc
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index a781dc47984040f8b8c5843e8045e420e4ef8124..da4d267cfccabbeb4723a0a847837e4182c4b007 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -35,6 +35,9 @@ TEST(ValuesTest, TestNothrow) {
"IsNothrowMoveConstructibleFromList");
static_assert(std::is_nothrow_move_assignable<Value>::value,
"IsNothrowMoveAssignable");
+ static_assert(
+ std::is_nothrow_constructible<ListValue, Value::ListStorage&&>::value,
+ "ListIsNothrowMoveConstructibleFromList");
}
// Group of tests for the value constructors.
@@ -119,6 +122,28 @@ TEST(ValuesTest, ConstructList) {
EXPECT_EQ(Value::Type::LIST, value.type());
}
+TEST(ValuesTest, ConstructListFromStorage) {
+ Value::ListStorage storage;
+ storage.emplace_back("foo");
+
+ {
+ ListValue value(storage);
+ EXPECT_EQ(Value::Type::LIST, value.type());
+ EXPECT_EQ(1u, value.GetList().size());
+ EXPECT_EQ(Value::Type::STRING, value.GetList()[0].type());
+ EXPECT_EQ("foo", value.GetList()[0].GetString());
+ }
+
+ storage.back() = base::Value("bar");
+ {
+ ListValue value(std::move(storage));
+ EXPECT_EQ(Value::Type::LIST, value.type());
+ EXPECT_EQ(1u, value.GetList().size());
+ EXPECT_EQ(Value::Type::STRING, value.GetList()[0].type());
+ EXPECT_EQ("bar", value.GetList()[0].GetString());
+ }
+}
+
// Group of tests for the copy constructors and copy-assigmnent. For equality
// checks comparisons of the interesting fields are done instead of relying on
// Equals being correct.
« no previous file with comments | « base/values.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698