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

Side by Side Diff: base/values_unittest.cc

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Comment Updates Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/values.h" 5 #include "base/values.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); 414 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value));
415 ASSERT_EQ(88.8, double_value); 415 ASSERT_EQ(88.8, double_value);
416 ASSERT_TRUE(mixed_list->GetString(3, &string_value)); 416 ASSERT_TRUE(mixed_list->GetString(3, &string_value));
417 ASSERT_EQ("foo", string_value); 417 ASSERT_EQ("foo", string_value);
418 418
419 // Try searching in the mixed list. 419 // Try searching in the mixed list.
420 base::Value sought_value(42); 420 base::Value sought_value(42);
421 base::Value not_found_value(false); 421 base::Value not_found_value(false);
422 422
423 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value)); 423 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value));
424 ASSERT_TRUE((*mixed_list->Find(sought_value))->GetAsInteger(&int_value)); 424 ASSERT_TRUE((*mixed_list->Find(sought_value)).GetAsInteger(&int_value));
425 ASSERT_EQ(42, int_value); 425 ASSERT_EQ(42, int_value);
426 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value)); 426 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value));
427 } 427 }
428 428
429 TEST(ValuesTest, BinaryValue) { 429 TEST(ValuesTest, BinaryValue) {
430 // Default constructor creates a BinaryValue with a buffer of size 0. 430 // Default constructor creates a BinaryValue with a buffer of size 0.
431 auto binary = MakeUnique<Value>(Value::Type::BINARY); 431 auto binary = MakeUnique<Value>(Value::Type::BINARY);
432 ASSERT_TRUE(binary.get()); 432 ASSERT_TRUE(binary.get());
433 ASSERT_EQ(0U, binary->GetSize()); 433 ASSERT_EQ(0U, binary->GetSize());
434 434
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 { 517 {
518 ListValue list; 518 ListValue list;
519 list.Append(MakeUnique<Value>()); 519 list.Append(MakeUnique<Value>());
520 EXPECT_TRUE(list.Remove(0, NULL)); 520 EXPECT_TRUE(list.Remove(0, NULL));
521 EXPECT_EQ(0U, list.GetSize()); 521 EXPECT_EQ(0U, list.GetSize());
522 } 522 }
523 523
524 { 524 {
525 ListValue list; 525 ListValue list;
526 auto value = MakeUnique<Value>(); 526 auto value = MakeUnique<Value>();
527 Value* original_value = value.get(); 527 Value original_value = *value;
528 list.Append(std::move(value)); 528 list.Append(std::move(value));
529 size_t index = 0; 529 size_t index = 0;
530 list.Remove(*original_value, &index); 530 list.Remove(original_value, &index);
531 EXPECT_EQ(0U, index); 531 EXPECT_EQ(0U, index);
532 EXPECT_EQ(0U, list.GetSize()); 532 EXPECT_EQ(0U, list.GetSize());
533 } 533 }
534 } 534 }
535 535
536 TEST(ValuesTest, DictionaryDeletion) { 536 TEST(ValuesTest, DictionaryDeletion) {
537 std::string key = "test"; 537 std::string key = "test";
538 DictionaryValue dict; 538 DictionaryValue dict;
539 dict.Set(key, MakeUnique<Value>()); 539 dict.Set(key, MakeUnique<Value>());
540 EXPECT_FALSE(dict.empty()); 540 EXPECT_FALSE(dict.empty());
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 EXPECT_FALSE(main_list.GetList(1, NULL)); 1377 EXPECT_FALSE(main_list.GetList(1, NULL));
1378 EXPECT_FALSE(main_list.GetList(2, NULL)); 1378 EXPECT_FALSE(main_list.GetList(2, NULL));
1379 EXPECT_FALSE(main_list.GetList(3, NULL)); 1379 EXPECT_FALSE(main_list.GetList(3, NULL));
1380 EXPECT_FALSE(main_list.GetList(4, NULL)); 1380 EXPECT_FALSE(main_list.GetList(4, NULL));
1381 EXPECT_FALSE(main_list.GetList(5, NULL)); 1381 EXPECT_FALSE(main_list.GetList(5, NULL));
1382 EXPECT_TRUE(main_list.GetList(6, NULL)); 1382 EXPECT_TRUE(main_list.GetList(6, NULL));
1383 EXPECT_FALSE(main_list.GetList(7, NULL)); 1383 EXPECT_FALSE(main_list.GetList(7, NULL));
1384 } 1384 }
1385 1385
1386 } // namespace base 1386 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698