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

Unified Diff: base/json/json_value_converter_unittest.cc

Issue 9187047: Use ScopedVector instead of std::vector in case of repeated messages. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« base/json/json_value_converter.h ('K') | « base/json/json_value_converter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_value_converter_unittest.cc
diff --git a/base/json/json_value_converter_unittest.cc b/base/json/json_value_converter_unittest.cc
index 73ed2299f1fc1565287906ef22237bd8a31f9050..71167f09fc4413775463b02aeb76cb89d717e007 100644
--- a/base/json/json_value_converter_unittest.cc
+++ b/base/json/json_value_converter_unittest.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "base/json/json_reader.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -36,7 +37,7 @@ struct SimpleMessage {
struct NestedMessage {
double foo;
SimpleMessage child;
- std::vector<SimpleMessage> children;
+ ScopedVector<SimpleMessage> children;
NestedMessage() : foo(0) {}
@@ -104,15 +105,17 @@ TEST(JSONValueConverterTest, ParseNestedMessage) {
EXPECT_TRUE(message.child.baz);
EXPECT_EQ(2, static_cast<int>(message.children.size()));
- const SimpleMessage& first_child = message.children[0];
- EXPECT_EQ(2, first_child.foo);
- EXPECT_EQ("foobar", first_child.bar);
- EXPECT_TRUE(first_child.baz);
-
- const SimpleMessage& second_child = message.children[1];
- EXPECT_EQ(3, second_child.foo);
- EXPECT_EQ("barbaz", second_child.bar);
- EXPECT_FALSE(second_child.baz);
+ const SimpleMessage* first_child = message.children[0];
+ ASSERT_TRUE(first_child);
+ EXPECT_EQ(2, first_child->foo);
+ EXPECT_EQ("foobar", first_child->bar);
+ EXPECT_TRUE(first_child->baz);
+
+ const SimpleMessage* second_child = message.children[1];
+ ASSERT_TRUE(second_child);
+ EXPECT_EQ(3, second_child->foo);
+ EXPECT_EQ("barbaz", second_child->bar);
+ EXPECT_FALSE(second_child->baz);
}
TEST(JSONValueConverterTest, ParseFailures) {
« base/json/json_value_converter.h ('K') | « base/json/json_value_converter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698