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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 std::string bookmark_name = "Unnamed"; | 55 std::string bookmark_name = "Unnamed"; |
56 ASSERT_TRUE(bookmark->GetString("name", &bookmark_name)); | 56 ASSERT_TRUE(bookmark->GetString("name", &bookmark_name)); |
57 ASSERT_EQ(std::string("Froogle"), bookmark_name); | 57 ASSERT_EQ(std::string("Froogle"), bookmark_name); |
58 std::string bookmark_url; | 58 std::string bookmark_url; |
59 ASSERT_TRUE(bookmark->GetString("url", &bookmark_url)); | 59 ASSERT_TRUE(bookmark->GetString("url", &bookmark_url)); |
60 ASSERT_EQ(std::string("http://froogle.com"), bookmark_url); | 60 ASSERT_EQ(std::string("http://froogle.com"), bookmark_url); |
61 } | 61 } |
62 | 62 |
63 TEST(ValuesTest, List) { | 63 TEST(ValuesTest, List) { |
64 std::unique_ptr<ListValue> mixed_list(new ListValue()); | 64 std::unique_ptr<ListValue> mixed_list(new ListValue()); |
65 mixed_list->Set(0, MakeUnique<FundamentalValue>(true)); | 65 mixed_list->Set(0, MakeUnique<Value>(true)); |
66 mixed_list->Set(1, MakeUnique<FundamentalValue>(42)); | 66 mixed_list->Set(1, MakeUnique<Value>(42)); |
67 mixed_list->Set(2, MakeUnique<FundamentalValue>(88.8)); | 67 mixed_list->Set(2, MakeUnique<Value>(88.8)); |
68 mixed_list->Set(3, MakeUnique<StringValue>("foo")); | 68 mixed_list->Set(3, MakeUnique<StringValue>("foo")); |
69 ASSERT_EQ(4u, mixed_list->GetSize()); | 69 ASSERT_EQ(4u, mixed_list->GetSize()); |
70 | 70 |
71 Value *value = NULL; | 71 Value *value = NULL; |
72 bool bool_value = false; | 72 bool bool_value = false; |
73 int int_value = 0; | 73 int int_value = 0; |
74 double double_value = 0.0; | 74 double double_value = 0.0; |
75 std::string string_value; | 75 std::string string_value; |
76 | 76 |
77 ASSERT_FALSE(mixed_list->Get(4, &value)); | 77 ASSERT_FALSE(mixed_list->Get(4, &value)); |
(...skipping 15 matching lines...) Expand all Loading... |
93 ASSERT_EQ(42, int_value); | 93 ASSERT_EQ(42, int_value); |
94 // implicit conversion from Integer to Double should be possible. | 94 // implicit conversion from Integer to Double should be possible. |
95 ASSERT_TRUE(mixed_list->GetDouble(1, &double_value)); | 95 ASSERT_TRUE(mixed_list->GetDouble(1, &double_value)); |
96 ASSERT_EQ(42, double_value); | 96 ASSERT_EQ(42, double_value); |
97 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); | 97 ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); |
98 ASSERT_EQ(88.8, double_value); | 98 ASSERT_EQ(88.8, double_value); |
99 ASSERT_TRUE(mixed_list->GetString(3, &string_value)); | 99 ASSERT_TRUE(mixed_list->GetString(3, &string_value)); |
100 ASSERT_EQ("foo", string_value); | 100 ASSERT_EQ("foo", string_value); |
101 | 101 |
102 // Try searching in the mixed list. | 102 // Try searching in the mixed list. |
103 base::FundamentalValue sought_value(42); | 103 base::Value sought_value(42); |
104 base::FundamentalValue not_found_value(false); | 104 base::Value not_found_value(false); |
105 | 105 |
106 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value)); | 106 ASSERT_NE(mixed_list->end(), mixed_list->Find(sought_value)); |
107 ASSERT_TRUE((*mixed_list->Find(sought_value))->GetAsInteger(&int_value)); | 107 ASSERT_TRUE((*mixed_list->Find(sought_value))->GetAsInteger(&int_value)); |
108 ASSERT_EQ(42, int_value); | 108 ASSERT_EQ(42, int_value); |
109 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value)); | 109 ASSERT_EQ(mixed_list->end(), mixed_list->Find(not_found_value)); |
110 } | 110 } |
111 | 111 |
112 TEST(ValuesTest, BinaryValue) { | 112 TEST(ValuesTest, BinaryValue) { |
113 // Default constructor creates a BinaryValue with a null buffer and size 0. | 113 // Default constructor creates a BinaryValue with a null buffer and size 0. |
114 std::unique_ptr<BinaryValue> binary(new BinaryValue()); | 114 std::unique_ptr<BinaryValue> binary(new BinaryValue()); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 ASSERT_TRUE(removed_item); | 393 ASSERT_TRUE(removed_item); |
394 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_BOOLEAN)); | 394 EXPECT_TRUE(removed_item->IsType(base::Value::TYPE_BOOLEAN)); |
395 EXPECT_TRUE(dict.empty()); | 395 EXPECT_TRUE(dict.empty()); |
396 } | 396 } |
397 | 397 |
398 TEST(ValuesTest, DeepCopy) { | 398 TEST(ValuesTest, DeepCopy) { |
399 DictionaryValue original_dict; | 399 DictionaryValue original_dict; |
400 std::unique_ptr<Value> scoped_null = Value::CreateNullValue(); | 400 std::unique_ptr<Value> scoped_null = Value::CreateNullValue(); |
401 Value* original_null = scoped_null.get(); | 401 Value* original_null = scoped_null.get(); |
402 original_dict.Set("null", std::move(scoped_null)); | 402 original_dict.Set("null", std::move(scoped_null)); |
403 std::unique_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true)); | 403 std::unique_ptr<Value> scoped_bool(new Value(true)); |
404 FundamentalValue* original_bool = scoped_bool.get(); | 404 Value* original_bool = scoped_bool.get(); |
405 original_dict.Set("bool", std::move(scoped_bool)); | 405 original_dict.Set("bool", std::move(scoped_bool)); |
406 std::unique_ptr<FundamentalValue> scoped_int(new FundamentalValue(42)); | 406 std::unique_ptr<Value> scoped_int(new Value(42)); |
407 FundamentalValue* original_int = scoped_int.get(); | 407 Value* original_int = scoped_int.get(); |
408 original_dict.Set("int", std::move(scoped_int)); | 408 original_dict.Set("int", std::move(scoped_int)); |
409 std::unique_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14)); | 409 std::unique_ptr<Value> scoped_double(new Value(3.14)); |
410 FundamentalValue* original_double = scoped_double.get(); | 410 Value* original_double = scoped_double.get(); |
411 original_dict.Set("double", std::move(scoped_double)); | 411 original_dict.Set("double", std::move(scoped_double)); |
412 std::unique_ptr<StringValue> scoped_string(new StringValue("hello")); | 412 std::unique_ptr<StringValue> scoped_string(new StringValue("hello")); |
413 StringValue* original_string = scoped_string.get(); | 413 StringValue* original_string = scoped_string.get(); |
414 original_dict.Set("string", std::move(scoped_string)); | 414 original_dict.Set("string", std::move(scoped_string)); |
415 std::unique_ptr<StringValue> scoped_string16( | 415 std::unique_ptr<StringValue> scoped_string16( |
416 new StringValue(ASCIIToUTF16("hello16"))); | 416 new StringValue(ASCIIToUTF16("hello16"))); |
417 StringValue* original_string16 = scoped_string16.get(); | 417 StringValue* original_string16 = scoped_string16.get(); |
418 original_dict.Set("string16", std::move(scoped_string16)); | 418 original_dict.Set("string16", std::move(scoped_string16)); |
419 | 419 |
420 std::unique_ptr<char[]> original_buffer(new char[42]); | 420 std::unique_ptr<char[]> original_buffer(new char[42]); |
421 memset(original_buffer.get(), '!', 42); | 421 memset(original_buffer.get(), '!', 42); |
422 std::unique_ptr<BinaryValue> scoped_binary( | 422 std::unique_ptr<BinaryValue> scoped_binary( |
423 new BinaryValue(std::move(original_buffer), 42)); | 423 new BinaryValue(std::move(original_buffer), 42)); |
424 BinaryValue* original_binary = scoped_binary.get(); | 424 BinaryValue* original_binary = scoped_binary.get(); |
425 original_dict.Set("binary", std::move(scoped_binary)); | 425 original_dict.Set("binary", std::move(scoped_binary)); |
426 | 426 |
427 std::unique_ptr<ListValue> scoped_list(new ListValue()); | 427 std::unique_ptr<ListValue> scoped_list(new ListValue()); |
428 Value* original_list = scoped_list.get(); | 428 Value* original_list = scoped_list.get(); |
429 std::unique_ptr<FundamentalValue> scoped_list_element_0( | 429 std::unique_ptr<Value> scoped_list_element_0( |
430 new FundamentalValue(0)); | 430 new Value(0)); |
431 Value* original_list_element_0 = scoped_list_element_0.get(); | 431 Value* original_list_element_0 = scoped_list_element_0.get(); |
432 scoped_list->Append(std::move(scoped_list_element_0)); | 432 scoped_list->Append(std::move(scoped_list_element_0)); |
433 std::unique_ptr<FundamentalValue> scoped_list_element_1( | 433 std::unique_ptr<Value> scoped_list_element_1( |
434 new FundamentalValue(1)); | 434 new Value(1)); |
435 Value* original_list_element_1 = scoped_list_element_1.get(); | 435 Value* original_list_element_1 = scoped_list_element_1.get(); |
436 scoped_list->Append(std::move(scoped_list_element_1)); | 436 scoped_list->Append(std::move(scoped_list_element_1)); |
437 original_dict.Set("list", std::move(scoped_list)); | 437 original_dict.Set("list", std::move(scoped_list)); |
438 | 438 |
439 std::unique_ptr<DictionaryValue> scoped_nested_dictionary( | 439 std::unique_ptr<DictionaryValue> scoped_nested_dictionary( |
440 new DictionaryValue()); | 440 new DictionaryValue()); |
441 Value* original_nested_dictionary = scoped_nested_dictionary.get(); | 441 Value* original_nested_dictionary = scoped_nested_dictionary.get(); |
442 scoped_nested_dictionary->SetString("key", "value"); | 442 scoped_nested_dictionary->SetString("key", "value"); |
443 original_dict.Set("dictionary", std::move(scoped_nested_dictionary)); | 443 original_dict.Set("dictionary", std::move(scoped_nested_dictionary)); |
444 | 444 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ASSERT_TRUE(copy_nested_dictionary); | 550 ASSERT_TRUE(copy_nested_dictionary); |
551 EXPECT_TRUE(copy_nested_dictionary->HasKey("key")); | 551 EXPECT_TRUE(copy_nested_dictionary->HasKey("key")); |
552 } | 552 } |
553 | 553 |
554 TEST(ValuesTest, Equals) { | 554 TEST(ValuesTest, Equals) { |
555 std::unique_ptr<Value> null1(Value::CreateNullValue()); | 555 std::unique_ptr<Value> null1(Value::CreateNullValue()); |
556 std::unique_ptr<Value> null2(Value::CreateNullValue()); | 556 std::unique_ptr<Value> null2(Value::CreateNullValue()); |
557 EXPECT_NE(null1.get(), null2.get()); | 557 EXPECT_NE(null1.get(), null2.get()); |
558 EXPECT_TRUE(null1->Equals(null2.get())); | 558 EXPECT_TRUE(null1->Equals(null2.get())); |
559 | 559 |
560 FundamentalValue boolean(false); | 560 Value boolean(false); |
561 EXPECT_FALSE(null1->Equals(&boolean)); | 561 EXPECT_FALSE(null1->Equals(&boolean)); |
562 | 562 |
563 DictionaryValue dv; | 563 DictionaryValue dv; |
564 dv.SetBoolean("a", false); | 564 dv.SetBoolean("a", false); |
565 dv.SetInteger("b", 2); | 565 dv.SetInteger("b", 2); |
566 dv.SetDouble("c", 2.5); | 566 dv.SetDouble("c", 2.5); |
567 dv.SetString("d1", "string"); | 567 dv.SetString("d1", "string"); |
568 dv.SetString("d2", ASCIIToUTF16("http://google.com")); | 568 dv.SetString("d2", ASCIIToUTF16("http://google.com")); |
569 dv.Set("e", Value::CreateNullValue()); | 569 dv.Set("e", Value::CreateNullValue()); |
570 | 570 |
571 std::unique_ptr<DictionaryValue> copy = dv.CreateDeepCopy(); | 571 std::unique_ptr<DictionaryValue> copy = dv.CreateDeepCopy(); |
572 EXPECT_TRUE(dv.Equals(copy.get())); | 572 EXPECT_TRUE(dv.Equals(copy.get())); |
573 | 573 |
574 std::unique_ptr<ListValue> list(new ListValue); | 574 std::unique_ptr<ListValue> list(new ListValue); |
575 ListValue* original_list = list.get(); | 575 ListValue* original_list = list.get(); |
576 list->Append(Value::CreateNullValue()); | 576 list->Append(Value::CreateNullValue()); |
577 list->Append(WrapUnique(new DictionaryValue)); | 577 list->Append(WrapUnique(new DictionaryValue)); |
578 std::unique_ptr<Value> list_copy(list->CreateDeepCopy()); | 578 std::unique_ptr<Value> list_copy(list->CreateDeepCopy()); |
579 | 579 |
580 dv.Set("f", std::move(list)); | 580 dv.Set("f", std::move(list)); |
581 EXPECT_FALSE(dv.Equals(copy.get())); | 581 EXPECT_FALSE(dv.Equals(copy.get())); |
582 copy->Set("f", std::move(list_copy)); | 582 copy->Set("f", std::move(list_copy)); |
583 EXPECT_TRUE(dv.Equals(copy.get())); | 583 EXPECT_TRUE(dv.Equals(copy.get())); |
584 | 584 |
585 original_list->Append(MakeUnique<FundamentalValue>(true)); | 585 original_list->Append(MakeUnique<Value>(true)); |
586 EXPECT_FALSE(dv.Equals(copy.get())); | 586 EXPECT_FALSE(dv.Equals(copy.get())); |
587 | 587 |
588 // Check if Equals detects differences in only the keys. | 588 // Check if Equals detects differences in only the keys. |
589 copy = dv.CreateDeepCopy(); | 589 copy = dv.CreateDeepCopy(); |
590 EXPECT_TRUE(dv.Equals(copy.get())); | 590 EXPECT_TRUE(dv.Equals(copy.get())); |
591 copy->Remove("a", NULL); | 591 copy->Remove("a", NULL); |
592 copy->SetBoolean("aa", false); | 592 copy->SetBoolean("aa", false); |
593 EXPECT_FALSE(dv.Equals(copy.get())); | 593 EXPECT_FALSE(dv.Equals(copy.get())); |
594 } | 594 } |
595 | 595 |
596 TEST(ValuesTest, StaticEquals) { | 596 TEST(ValuesTest, StaticEquals) { |
597 std::unique_ptr<Value> null1(Value::CreateNullValue()); | 597 std::unique_ptr<Value> null1(Value::CreateNullValue()); |
598 std::unique_ptr<Value> null2(Value::CreateNullValue()); | 598 std::unique_ptr<Value> null2(Value::CreateNullValue()); |
599 EXPECT_TRUE(Value::Equals(null1.get(), null2.get())); | 599 EXPECT_TRUE(Value::Equals(null1.get(), null2.get())); |
600 EXPECT_TRUE(Value::Equals(NULL, NULL)); | 600 EXPECT_TRUE(Value::Equals(NULL, NULL)); |
601 | 601 |
602 std::unique_ptr<Value> i42(new FundamentalValue(42)); | 602 std::unique_ptr<Value> i42(new Value(42)); |
603 std::unique_ptr<Value> j42(new FundamentalValue(42)); | 603 std::unique_ptr<Value> j42(new Value(42)); |
604 std::unique_ptr<Value> i17(new FundamentalValue(17)); | 604 std::unique_ptr<Value> i17(new Value(17)); |
605 EXPECT_TRUE(Value::Equals(i42.get(), i42.get())); | 605 EXPECT_TRUE(Value::Equals(i42.get(), i42.get())); |
606 EXPECT_TRUE(Value::Equals(j42.get(), i42.get())); | 606 EXPECT_TRUE(Value::Equals(j42.get(), i42.get())); |
607 EXPECT_TRUE(Value::Equals(i42.get(), j42.get())); | 607 EXPECT_TRUE(Value::Equals(i42.get(), j42.get())); |
608 EXPECT_FALSE(Value::Equals(i42.get(), i17.get())); | 608 EXPECT_FALSE(Value::Equals(i42.get(), i17.get())); |
609 EXPECT_FALSE(Value::Equals(i42.get(), NULL)); | 609 EXPECT_FALSE(Value::Equals(i42.get(), NULL)); |
610 EXPECT_FALSE(Value::Equals(NULL, i42.get())); | 610 EXPECT_FALSE(Value::Equals(NULL, i42.get())); |
611 | 611 |
612 // NULL and Value::CreateNullValue() are intentionally different: We need | 612 // NULL and Value::CreateNullValue() are intentionally different: We need |
613 // support for NULL as a return value for "undefined" without caring for | 613 // support for NULL as a return value for "undefined" without caring for |
614 // ownership of the pointer. | 614 // ownership of the pointer. |
615 EXPECT_FALSE(Value::Equals(null1.get(), NULL)); | 615 EXPECT_FALSE(Value::Equals(null1.get(), NULL)); |
616 EXPECT_FALSE(Value::Equals(NULL, null1.get())); | 616 EXPECT_FALSE(Value::Equals(NULL, null1.get())); |
617 } | 617 } |
618 | 618 |
619 TEST(ValuesTest, DeepCopyCovariantReturnTypes) { | 619 TEST(ValuesTest, DeepCopyCovariantReturnTypes) { |
620 DictionaryValue original_dict; | 620 DictionaryValue original_dict; |
621 std::unique_ptr<Value> scoped_null(Value::CreateNullValue()); | 621 std::unique_ptr<Value> scoped_null(Value::CreateNullValue()); |
622 Value* original_null = scoped_null.get(); | 622 Value* original_null = scoped_null.get(); |
623 original_dict.Set("null", std::move(scoped_null)); | 623 original_dict.Set("null", std::move(scoped_null)); |
624 std::unique_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true)); | 624 std::unique_ptr<Value> scoped_bool(new Value(true)); |
625 Value* original_bool = scoped_bool.get(); | 625 Value* original_bool = scoped_bool.get(); |
626 original_dict.Set("bool", std::move(scoped_bool)); | 626 original_dict.Set("bool", std::move(scoped_bool)); |
627 std::unique_ptr<FundamentalValue> scoped_int(new FundamentalValue(42)); | 627 std::unique_ptr<Value> scoped_int(new Value(42)); |
628 Value* original_int = scoped_int.get(); | 628 Value* original_int = scoped_int.get(); |
629 original_dict.Set("int", std::move(scoped_int)); | 629 original_dict.Set("int", std::move(scoped_int)); |
630 std::unique_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14)); | 630 std::unique_ptr<Value> scoped_double(new Value(3.14)); |
631 Value* original_double = scoped_double.get(); | 631 Value* original_double = scoped_double.get(); |
632 original_dict.Set("double", std::move(scoped_double)); | 632 original_dict.Set("double", std::move(scoped_double)); |
633 std::unique_ptr<StringValue> scoped_string(new StringValue("hello")); | 633 std::unique_ptr<StringValue> scoped_string(new StringValue("hello")); |
634 Value* original_string = scoped_string.get(); | 634 Value* original_string = scoped_string.get(); |
635 original_dict.Set("string", std::move(scoped_string)); | 635 original_dict.Set("string", std::move(scoped_string)); |
636 std::unique_ptr<StringValue> scoped_string16( | 636 std::unique_ptr<StringValue> scoped_string16( |
637 new StringValue(ASCIIToUTF16("hello16"))); | 637 new StringValue(ASCIIToUTF16("hello16"))); |
638 Value* original_string16 = scoped_string16.get(); | 638 Value* original_string16 = scoped_string16.get(); |
639 original_dict.Set("string16", std::move(scoped_string16)); | 639 original_dict.Set("string16", std::move(scoped_string16)); |
640 | 640 |
641 std::unique_ptr<char[]> original_buffer(new char[42]); | 641 std::unique_ptr<char[]> original_buffer(new char[42]); |
642 memset(original_buffer.get(), '!', 42); | 642 memset(original_buffer.get(), '!', 42); |
643 std::unique_ptr<BinaryValue> scoped_binary( | 643 std::unique_ptr<BinaryValue> scoped_binary( |
644 new BinaryValue(std::move(original_buffer), 42)); | 644 new BinaryValue(std::move(original_buffer), 42)); |
645 Value* original_binary = scoped_binary.get(); | 645 Value* original_binary = scoped_binary.get(); |
646 original_dict.Set("binary", std::move(scoped_binary)); | 646 original_dict.Set("binary", std::move(scoped_binary)); |
647 | 647 |
648 std::unique_ptr<ListValue> scoped_list(new ListValue()); | 648 std::unique_ptr<ListValue> scoped_list(new ListValue()); |
649 Value* original_list = scoped_list.get(); | 649 Value* original_list = scoped_list.get(); |
650 std::unique_ptr<FundamentalValue> scoped_list_element_0( | 650 std::unique_ptr<Value> scoped_list_element_0( |
651 new FundamentalValue(0)); | 651 new Value(0)); |
652 scoped_list->Append(std::move(scoped_list_element_0)); | 652 scoped_list->Append(std::move(scoped_list_element_0)); |
653 std::unique_ptr<FundamentalValue> scoped_list_element_1( | 653 std::unique_ptr<Value> scoped_list_element_1( |
654 new FundamentalValue(1)); | 654 new Value(1)); |
655 scoped_list->Append(std::move(scoped_list_element_1)); | 655 scoped_list->Append(std::move(scoped_list_element_1)); |
656 original_dict.Set("list", std::move(scoped_list)); | 656 original_dict.Set("list", std::move(scoped_list)); |
657 | 657 |
658 std::unique_ptr<Value> copy_dict = original_dict.CreateDeepCopy(); | 658 std::unique_ptr<Value> copy_dict = original_dict.CreateDeepCopy(); |
659 std::unique_ptr<Value> copy_null = original_null->CreateDeepCopy(); | 659 std::unique_ptr<Value> copy_null = original_null->CreateDeepCopy(); |
660 std::unique_ptr<Value> copy_bool = original_bool->CreateDeepCopy(); | 660 std::unique_ptr<Value> copy_bool = original_bool->CreateDeepCopy(); |
661 std::unique_ptr<Value> copy_int = original_int->CreateDeepCopy(); | 661 std::unique_ptr<Value> copy_int = original_int->CreateDeepCopy(); |
662 std::unique_ptr<Value> copy_double = original_double->CreateDeepCopy(); | 662 std::unique_ptr<Value> copy_double = original_double->CreateDeepCopy(); |
663 std::unique_ptr<Value> copy_string = original_string->CreateDeepCopy(); | 663 std::unique_ptr<Value> copy_string = original_string->CreateDeepCopy(); |
664 std::unique_ptr<Value> copy_string16 = original_string16->CreateDeepCopy(); | 664 std::unique_ptr<Value> copy_string16 = original_string16->CreateDeepCopy(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 EXPECT_TRUE(seen1); | 867 EXPECT_TRUE(seen1); |
868 EXPECT_TRUE(seen2); | 868 EXPECT_TRUE(seen2); |
869 } | 869 } |
870 | 870 |
871 // DictionaryValue/ListValue's Get*() methods should accept NULL as an out-value | 871 // DictionaryValue/ListValue's Get*() methods should accept NULL as an out-value |
872 // and still return true/false based on success. | 872 // and still return true/false based on success. |
873 TEST(ValuesTest, GetWithNullOutValue) { | 873 TEST(ValuesTest, GetWithNullOutValue) { |
874 DictionaryValue main_dict; | 874 DictionaryValue main_dict; |
875 ListValue main_list; | 875 ListValue main_list; |
876 | 876 |
877 FundamentalValue bool_value(false); | 877 Value bool_value(false); |
878 FundamentalValue int_value(1234); | 878 Value int_value(1234); |
879 FundamentalValue double_value(12.34567); | 879 Value double_value(12.34567); |
880 StringValue string_value("foo"); | 880 StringValue string_value("foo"); |
881 BinaryValue binary_value; | 881 BinaryValue binary_value; |
882 DictionaryValue dict_value; | 882 DictionaryValue dict_value; |
883 ListValue list_value; | 883 ListValue list_value; |
884 | 884 |
885 main_dict.Set("bool", bool_value.CreateDeepCopy()); | 885 main_dict.Set("bool", bool_value.CreateDeepCopy()); |
886 main_dict.Set("int", int_value.CreateDeepCopy()); | 886 main_dict.Set("int", int_value.CreateDeepCopy()); |
887 main_dict.Set("double", double_value.CreateDeepCopy()); | 887 main_dict.Set("double", double_value.CreateDeepCopy()); |
888 main_dict.Set("string", string_value.CreateDeepCopy()); | 888 main_dict.Set("string", string_value.CreateDeepCopy()); |
889 main_dict.Set("binary", binary_value.CreateDeepCopy()); | 889 main_dict.Set("binary", binary_value.CreateDeepCopy()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 EXPECT_FALSE(main_list.GetList(1, NULL)); | 1147 EXPECT_FALSE(main_list.GetList(1, NULL)); |
1148 EXPECT_FALSE(main_list.GetList(2, NULL)); | 1148 EXPECT_FALSE(main_list.GetList(2, NULL)); |
1149 EXPECT_FALSE(main_list.GetList(3, NULL)); | 1149 EXPECT_FALSE(main_list.GetList(3, NULL)); |
1150 EXPECT_FALSE(main_list.GetList(4, NULL)); | 1150 EXPECT_FALSE(main_list.GetList(4, NULL)); |
1151 EXPECT_FALSE(main_list.GetList(5, NULL)); | 1151 EXPECT_FALSE(main_list.GetList(5, NULL)); |
1152 EXPECT_TRUE(main_list.GetList(6, NULL)); | 1152 EXPECT_TRUE(main_list.GetList(6, NULL)); |
1153 EXPECT_FALSE(main_list.GetList(7, NULL)); | 1153 EXPECT_FALSE(main_list.GetList(7, NULL)); |
1154 } | 1154 } |
1155 | 1155 |
1156 } // namespace base | 1156 } // namespace base |
OLD | NEW |