OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ASSERT_TRUE(wide_value->GetAsString(&narrow)); | 143 ASSERT_TRUE(wide_value->GetAsString(&narrow)); |
144 ASSERT_TRUE(wide_value->GetAsString(&wide)); | 144 ASSERT_TRUE(wide_value->GetAsString(&wide)); |
145 ASSERT_EQ(std::string("wide"), narrow); | 145 ASSERT_EQ(std::string("wide"), narrow); |
146 ASSERT_EQ(std::wstring(L"wide"), wide); | 146 ASSERT_EQ(std::wstring(L"wide"), wide); |
147 } | 147 } |
148 | 148 |
149 // This is a Value object that allows us to tell if it's been | 149 // This is a Value object that allows us to tell if it's been |
150 // properly deleted by modifying the value of external flag on destruction. | 150 // properly deleted by modifying the value of external flag on destruction. |
151 class DeletionTestValue : public Value { | 151 class DeletionTestValue : public Value { |
152 public: | 152 public: |
153 DeletionTestValue(bool* deletion_flag) : Value(TYPE_NULL) { | 153 explicit DeletionTestValue(bool* deletion_flag) : Value(TYPE_NULL) { |
154 Init(deletion_flag); // Separate function so that we can use ASSERT_* | 154 Init(deletion_flag); // Separate function so that we can use ASSERT_* |
155 } | 155 } |
156 | 156 |
157 void Init(bool* deletion_flag) { | 157 void Init(bool* deletion_flag) { |
158 ASSERT_TRUE(deletion_flag); | 158 ASSERT_TRUE(deletion_flag); |
159 deletion_flag_ = deletion_flag; | 159 deletion_flag_ = deletion_flag; |
160 *deletion_flag_ = false; | 160 *deletion_flag_ = false; |
161 } | 161 } |
162 | 162 |
163 ~DeletionTestValue() { | 163 ~DeletionTestValue() { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 inner->Append(inner2); | 546 inner->Append(inner2); |
547 inner2->Append(Value::CreateStringValue("hello")); | 547 inner2->Append(Value::CreateStringValue("hello")); |
548 root.reset(root->DeepCopyWithoutEmptyChildren()); | 548 root.reset(root->DeepCopyWithoutEmptyChildren()); |
549 EXPECT_EQ(3U, root->size()); | 549 EXPECT_EQ(3U, root->size()); |
550 EXPECT_TRUE(root->GetList(L"list_with_empty_children", &inner)); | 550 EXPECT_TRUE(root->GetList(L"list_with_empty_children", &inner)); |
551 EXPECT_EQ(1U, inner->GetSize()); // Dictionary was pruned. | 551 EXPECT_EQ(1U, inner->GetSize()); // Dictionary was pruned. |
552 EXPECT_TRUE(inner->GetList(0, &inner2)); | 552 EXPECT_TRUE(inner->GetList(0, &inner2)); |
553 EXPECT_EQ(1U, inner2->GetSize()); | 553 EXPECT_EQ(1U, inner2->GetSize()); |
554 } | 554 } |
555 } | 555 } |
OLD | NEW |