Index: base/test/values_test_util.cc |
diff --git a/base/test/values_test_util.cc b/base/test/values_test_util.cc |
index a5667f14b81e9700ef6e248fb1a34efb183302fd..0dd99552a0ec1e206179a1fdbf453fe14300236a 100644 |
--- a/base/test/values_test_util.cc |
+++ b/base/test/values_test_util.cc |
@@ -2,9 +2,11 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/test/values_test_util.h" |
+ |
+#include "base/json/json_reader.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/string_number_conversions.h" |
-#include "base/test/values_test_util.h" |
#include "base/values.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -58,4 +60,16 @@ void ExpectStringValue(const std::string& expected_str, |
EXPECT_EQ(expected_str, actual_str); |
} |
+scoped_ptr<Value> ParseJson(base::StringPiece json) { |
Jeffrey Yasskin
2012/12/13 23:20:29
It might make sense to put this into a base::test
willchan no longer on Chromium
2012/12/14 20:35:04
It would make sense if I foresaw someone taking th
Jeffrey Yasskin
2012/12/14 23:12:41
I've moved it into base::test so that tests that w
|
+ std::string error_msg; |
+ scoped_ptr<Value> result(base::JSONReader::ReadAndReturnError( |
+ json, base::JSON_ALLOW_TRAILING_COMMAS, |
+ NULL, &error_msg)); |
+ if (!result) { |
+ ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg; |
+ result.reset(Value::CreateNullValue()); |
+ } |
+ return result.Pass(); |
+} |
+ |
} // namespace base |