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

Unified Diff: base/json/json_reader_unittest.cc

Issue 9860035: Fix handling of Unicode BOMs in JSONReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge origin/master Created 8 years, 9 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
« no previous file with comments | « base/json/json_reader.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_reader_unittest.cc
diff --git a/base/json/json_reader_unittest.cc b/base/json/json_reader_unittest.cc
index 5900781b9fb32657e060eebde04bfe6a74b6d714..467bf4d16fed0d1c021977fe6287945f9c31ce24 100644
--- a/base/json/json_reader_unittest.cc
+++ b/base/json/json_reader_unittest.cc
@@ -4,12 +4,15 @@
#include "base/json/json_reader.h"
-#include "testing/gtest/include/gtest/gtest.h"
+#include "base/base_paths.h"
+#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/path_service.h"
#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -500,6 +503,23 @@ TEST(JSONReaderTest, Reading) {
EXPECT_FALSE(root.get());
}
+TEST(JSONReaderTest, ReadFromFile) {
+ FilePath path;
+ ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path));
+ path = path.Append(FILE_PATH_LITERAL("base"))
+ .Append(FILE_PATH_LITERAL("data"))
+ .Append(FILE_PATH_LITERAL("json"));
+
+ std::string input;
+ ASSERT_TRUE(file_util::ReadFileToString(
+ path.Append(FILE_PATH_LITERAL("bom_feff.json")), &input));
+
+ JSONReader reader;
+ scoped_ptr<Value> root(reader.JsonToValue(input, false, false));
+ ASSERT_TRUE(root.get()) << reader.GetErrorMessage();
+ EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
+}
+
TEST(JSONReaderTest, ErrorMessages) {
// Error strings should not be modified in case of success.
std::string error_message;
« no previous file with comments | « base/json/json_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698