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

Side by Side Diff: base/values_unittest.cc

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Created 5 years, 11 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 <limits> 5 #include <limits>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ASSERT_EQ(15U, binary->GetSize()); 120 ASSERT_EQ(15U, binary->GetSize());
121 121
122 char stack_buffer[42]; 122 char stack_buffer[42];
123 memset(stack_buffer, '!', 42); 123 memset(stack_buffer, '!', 42);
124 binary.reset(BinaryValue::CreateWithCopiedBuffer(stack_buffer, 42)); 124 binary.reset(BinaryValue::CreateWithCopiedBuffer(stack_buffer, 42));
125 ASSERT_TRUE(binary.get()); 125 ASSERT_TRUE(binary.get());
126 ASSERT_TRUE(binary->GetBuffer()); 126 ASSERT_TRUE(binary->GetBuffer());
127 ASSERT_NE(stack_buffer, binary->GetBuffer()); 127 ASSERT_NE(stack_buffer, binary->GetBuffer());
128 ASSERT_EQ(42U, binary->GetSize()); 128 ASSERT_EQ(42U, binary->GetSize());
129 ASSERT_EQ(0, memcmp(stack_buffer, binary->GetBuffer(), binary->GetSize())); 129 ASSERT_EQ(0, memcmp(stack_buffer, binary->GetBuffer(), binary->GetSize()));
130
131 // Test overloaded GetAsBinary.
132 Value* narrow_value = binary.get();
133 const BinaryValue* narrow_binary = NULL;
Avi (use Gerrit) 2015/01/16 21:19:10 nullptr
134 ASSERT_TRUE(narrow_value->GetAsBinary(&narrow_binary));
135 EXPECT_EQ(binary.get(), narrow_binary);
130 } 136 }
131 137
132 TEST(ValuesTest, StringValue) { 138 TEST(ValuesTest, StringValue) {
133 // Test overloaded StringValue constructor. 139 // Test overloaded StringValue constructor.
134 scoped_ptr<Value> narrow_value(new StringValue("narrow")); 140 scoped_ptr<Value> narrow_value(new StringValue("narrow"));
135 ASSERT_TRUE(narrow_value.get()); 141 ASSERT_TRUE(narrow_value.get());
136 ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING)); 142 ASSERT_TRUE(narrow_value->IsType(Value::TYPE_STRING));
137 scoped_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16"))); 143 scoped_ptr<Value> utf16_value(new StringValue(ASCIIToUTF16("utf16")));
138 ASSERT_TRUE(utf16_value.get()); 144 ASSERT_TRUE(utf16_value.get());
139 ASSERT_TRUE(utf16_value->IsType(Value::TYPE_STRING)); 145 ASSERT_TRUE(utf16_value->IsType(Value::TYPE_STRING));
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 EXPECT_FALSE(main_list.GetList(1, NULL)); 1118 EXPECT_FALSE(main_list.GetList(1, NULL));
1113 EXPECT_FALSE(main_list.GetList(2, NULL)); 1119 EXPECT_FALSE(main_list.GetList(2, NULL));
1114 EXPECT_FALSE(main_list.GetList(3, NULL)); 1120 EXPECT_FALSE(main_list.GetList(3, NULL));
1115 EXPECT_FALSE(main_list.GetList(4, NULL)); 1121 EXPECT_FALSE(main_list.GetList(4, NULL));
1116 EXPECT_FALSE(main_list.GetList(5, NULL)); 1122 EXPECT_FALSE(main_list.GetList(5, NULL));
1117 EXPECT_TRUE(main_list.GetList(6, NULL)); 1123 EXPECT_TRUE(main_list.GetList(6, NULL));
1118 EXPECT_FALSE(main_list.GetList(7, NULL)); 1124 EXPECT_FALSE(main_list.GetList(7, NULL));
1119 } 1125 }
1120 1126
1121 } // namespace base 1127 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698