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

Unified Diff: base/values_unittest.cc

Issue 2834153002: 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 ae91658064d3fd54f2508e951cc2de0f58cc3875..fe1d84dd69a4c8d13ef05b8379a1d8ffc091c19a 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, std::vector<char>&&>::value,
"IsNothrowMoveConstructibleFromBlob");
+ static_assert(
+ std::is_nothrow_constructible<Value, Value::ListStorage&&>::value,
+ "IsNothrowMoveConstructibleFromList");
static_assert(std::is_nothrow_move_assignable<Value>::value,
"IsNothrowMoveAssignable");
}
@@ -215,25 +218,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.
@@ -332,22 +324,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