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

Unified Diff: base/json/json_parser_unittest.cc

Issue 12026035: Recognize "\r\n" line endings in base::JSONParser to report correct line numbers in errors (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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
« AUTHORS ('K') | « base/json/json_parser.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_parser_unittest.cc
===================================================================
--- base/json/json_parser_unittest.cc (revision 177738)
+++ base/json/json_parser_unittest.cc (working copy)
@@ -219,6 +219,17 @@
error_message);
EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code);
+ // Test line and column counting with "\r\n" line ending
+ const char* big_json_crlf =
Mark Mentovai 2013/02/04 17:41:00 This and line 212 should both be “const char xxx[]
+ "[\r\n0,\r\n1,\r\n2,\r\n3,4,5,6 7,\r\n8,\r\n9\r\n]";
Mark Mentovai 2013/02/04 17:41:00 This file uses four (not two) spaces of extra inde
+ // error here --------------------^
+ root.reset(JSONReader::ReadAndReturnError(big_json_crlf, JSON_PARSE_RFC,
+ &error_code, &error_message));
Mark Mentovai 2013/02/04 17:41:00 You haven’t cleared error_message or error_code fr
+ EXPECT_FALSE(root.get());
+ EXPECT_EQ(JSONParser::FormatErrorMessage(5, 10, JSONReader::kSyntaxError),
+ error_message);
+ EXPECT_EQ(JSONReader::JSON_SYNTAX_ERROR, error_code);
+
// Test each of the error conditions
root.reset(JSONReader::ReadAndReturnError("{},{}", JSON_PARSE_RFC,
&error_code, &error_message));
« AUTHORS ('K') | « base/json/json_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698