OLD | NEW |
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); | 430 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); |
431 ASSERT_EQ(88.8, double_value); | 431 ASSERT_EQ(88.8, double_value); |
432 ASSERT_TRUE(mixed_list->GetString(3, &string_value)); | 432 ASSERT_TRUE(mixed_list->GetString(3, &string_value)); |
433 ASSERT_EQ("foo", string_value); | 433 ASSERT_EQ("foo", string_value); |
434 | 434 |
435 // Try searching in the mixed list. | 435 // Try searching in the mixed list. |
436 base::Value sought_value(42); | 436 base::Value sought_value(42); |
437 base::Value not_found_value(false); | 437 base::Value not_found_value(false); |
438 | 438 |
439 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value)); | 439 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value)); |
440 ASSERT_TRUE((*mixed_list->Find(sought_value)).GetAsInteger(&int_value)); | 440 ASSERT_TRUE((*mixed_list->Find(sought_value))->GetAsInteger(&int_value)); |
441 ASSERT_EQ(42, int_value); | 441 ASSERT_EQ(42, int_value); |
442 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value)); | 442 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value)); |
443 } | 443 } |
444 | 444 |
445 TEST(ValuesTest, BinaryValue) { | 445 TEST(ValuesTest, BinaryValue) { |
446 // Default constructor creates a BinaryValue with a buffer of size 0. | 446 // Default constructor creates a BinaryValue with a buffer of size 0. |
447 auto binary = MakeUnique<Value>(Value::Type::BINARY); | 447 auto binary = MakeUnique<Value>(Value::Type::BINARY); |
448 ASSERT_TRUE(binary.get()); | 448 ASSERT_TRUE(binary.get()); |
449 ASSERT_EQ(0U, binary->GetSize()); | 449 ASSERT_EQ(0U, binary->GetSize()); |
450 | 450 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 { | 533 { |
534 ListValue list; | 534 ListValue list; |
535 list.Append(MakeUnique<Value>()); | 535 list.Append(MakeUnique<Value>()); |
536 EXPECT_TRUE(list.Remove(0, NULL)); | 536 EXPECT_TRUE(list.Remove(0, NULL)); |
537 EXPECT_EQ(0U, list.GetSize()); | 537 EXPECT_EQ(0U, list.GetSize()); |
538 } | 538 } |
539 | 539 |
540 { | 540 { |
541 ListValue list; | 541 ListValue list; |
542 auto value = MakeUnique<Value>(); | 542 auto value = MakeUnique<Value>(); |
543 Value original_value = *value; | 543 Value* original_value = value.get(); |
544 list.Append(std::move(value)); | 544 list.Append(std::move(value)); |
545 size_t index = 0; | 545 size_t index = 0; |
546 list.Remove(original_value, &index); | 546 list.Remove(*original_value, &index); |
547 EXPECT_EQ(0U, index); | 547 EXPECT_EQ(0U, index); |
548 EXPECT_EQ(0U, list.GetSize()); | 548 EXPECT_EQ(0U, list.GetSize()); |
549 } | 549 } |
550 } | 550 } |
551 | 551 |
552 TEST(ValuesTest, DictionaryDeletion) { | 552 TEST(ValuesTest, DictionaryDeletion) { |
553 std::string key = "test"; | 553 std::string key = "test"; |
554 DictionaryValue dict; | 554 DictionaryValue dict; |
555 dict.Set(key, MakeUnique<Value>()); | 555 dict.Set(key, MakeUnique<Value>()); |
556 EXPECT_FALSE(dict.empty()); | 556 EXPECT_FALSE(dict.empty()); |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 EXPECT_FALSE(main_list.GetList(7, NULL)); | 1517 EXPECT_FALSE(main_list.GetList(7, NULL)); |
1518 } | 1518 } |
1519 | 1519 |
1520 TEST(ValuesTest, SelfSwap) { | 1520 TEST(ValuesTest, SelfSwap) { |
1521 base::Value test(1); | 1521 base::Value test(1); |
1522 std::swap(test, test); | 1522 std::swap(test, test); |
1523 EXPECT_TRUE(test.GetInt() == 1); | 1523 EXPECT_TRUE(test.GetInt() == 1); |
1524 } | 1524 } |
1525 | 1525 |
1526 } // namespace base | 1526 } // namespace base |
OLD | NEW |