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

Unified Diff: base/values_unittest.cc

Issue 2823233002: Introduce Value::GetList and Value(ListStorage) (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 97807efe6eade5365d58dd36902a73a52087a5a9..de6cb8aedf99d0efc55ee8b9e99ef27faee27229 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -30,6 +30,9 @@ TEST(ValuesTest, TestNothrow) {
static_assert(
std::is_nothrow_constructible<Value, Value::BlobStorage&&>::value,
"IsNothrowMoveConstructibleFromBlob");
+ static_assert(
+ std::is_nothrow_constructible<Value, Value::ListStorage&&>::value,
+ "IsNothrowMoveConstructibleFromList");
static_assert(std::is_nothrow_move_assignable<Value>::value,
"IsNothrowMoveAssignable");
}
@@ -216,25 +219,14 @@ TEST(ValuesTest, CopyDictionary) {
}
TEST(ValuesTest, CopyList) {
- // TODO(crbug.com/646113): Clean this up once ListValue switched to
- // value semantics.
- int copy;
- ListValue value;
- value.AppendInteger(123);
-
- ListValue copied_value(value);
- copied_value.GetInteger(0, &copy);
+ Value value(Value::ListStorage{Value(123)});
- EXPECT_EQ(value.type(), copied_value.type());
- EXPECT_EQ(123, copy);
-
- auto blank = MakeUnique<Value>();
-
- *blank = value;
- EXPECT_EQ(Value::Type::LIST, blank->type());
+ Value copied_value(value);
+ EXPECT_EQ(value, copied_value);
- static_cast<ListValue*>(blank.get())->GetInteger(0, &copy);
- EXPECT_EQ(123, copy);
+ Value blank;
+ blank = value;
+ EXPECT_EQ(value, blank);
}
// Group of tests for the move constructors and move-assigmnent.
@@ -333,22 +325,17 @@ TEST(ValuesTest, MoveDictionary) {
}
TEST(ValuesTest, MoveList) {
- // TODO(crbug.com/646113): Clean this up once ListValue switched to
- // value semantics.
- int move;
- ListValue value;
- value.AppendInteger(123);
-
- ListValue moved_value(std::move(value));
- moved_value.GetInteger(0, &move);
-
+ const Value::ListStorage list = {Value(123)};
+ Value value(list);
+ Value moved_value(std::move(value));
EXPECT_EQ(Value::Type::LIST, moved_value.type());
- EXPECT_EQ(123, move);
+ EXPECT_EQ(123, moved_value.GetList().back().GetInt());
Value blank;
- blank = ListValue();
+ blank = Value(list);
EXPECT_EQ(Value::Type::LIST, blank.type());
+ EXPECT_EQ(123, blank.GetList().back().GetInt());
}
TEST(ValuesTest, Basic) {
« 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