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

Side by Side Diff: base/json_reader_unittest.cc

Issue 5628: Fixes bug where JSON reader errored on reading vertical tabs (\v). The... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/json_reader.cc ('k') | base/string_escape.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "base/json_reader.h" 6 #include "base/json_reader.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 TEST(JSONReaderTest, Reading) { 10 TEST(JSONReaderTest, Reading) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 ASSERT_TRUE(JSONReader::JsonToValue("\"\"", &root, false, false)); 207 ASSERT_TRUE(JSONReader::JsonToValue("\"\"", &root, false, false));
208 ASSERT_TRUE(root); 208 ASSERT_TRUE(root);
209 ASSERT_TRUE(root->IsType(Value::TYPE_STRING)); 209 ASSERT_TRUE(root->IsType(Value::TYPE_STRING));
210 str_val.clear(); 210 str_val.clear();
211 ASSERT_TRUE(root->GetAsString(&str_val)); 211 ASSERT_TRUE(root->GetAsString(&str_val));
212 ASSERT_EQ(L"", str_val); 212 ASSERT_EQ(L"", str_val);
213 delete root; 213 delete root;
214 214
215 // Test basic string escapes 215 // Test basic string escapes
216 root = NULL; 216 root = NULL;
217 ASSERT_TRUE(JSONReader::JsonToValue("\" \\\"\\\\\\/\\b\\f\\n\\r\\t\"", &root, 217 ASSERT_TRUE(JSONReader::JsonToValue("\" \\\"\\\\\\/\\b\\f\\n\\r\\t\\v\"", &roo t,
218 false, false)); 218 false, false));
219 ASSERT_TRUE(root); 219 ASSERT_TRUE(root);
220 ASSERT_TRUE(root->IsType(Value::TYPE_STRING)); 220 ASSERT_TRUE(root->IsType(Value::TYPE_STRING));
221 str_val.clear(); 221 str_val.clear();
222 ASSERT_TRUE(root->GetAsString(&str_val)); 222 ASSERT_TRUE(root->GetAsString(&str_val));
223 ASSERT_EQ(L" \"\\/\b\f\n\r\t", str_val); 223 ASSERT_EQ(L" \"\\/\b\f\n\r\t\v", str_val);
224 delete root; 224 delete root;
225 225
226 // Test hex and unicode escapes including the null character. 226 // Test hex and unicode escapes including the null character.
227 root = NULL; 227 root = NULL;
228 ASSERT_TRUE(JSONReader::JsonToValue("\"\\x41\\x00\\u1234\"", &root, false, 228 ASSERT_TRUE(JSONReader::JsonToValue("\"\\x41\\x00\\u1234\"", &root, false,
229 false)); 229 false));
230 ASSERT_TRUE(root); 230 ASSERT_TRUE(root);
231 ASSERT_TRUE(root->IsType(Value::TYPE_STRING)); 231 ASSERT_TRUE(root->IsType(Value::TYPE_STRING));
232 str_val.clear(); 232 str_val.clear();
233 ASSERT_TRUE(root->GetAsString(&str_val)); 233 ASSERT_TRUE(root->GetAsString(&str_val));
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 false, false)); 489 false, false));
490 490
491 // Test invalid root objects. 491 // Test invalid root objects.
492 root = NULL; 492 root = NULL;
493 ASSERT_FALSE(JSONReader::Read("null", &root, false)); 493 ASSERT_FALSE(JSONReader::Read("null", &root, false));
494 ASSERT_FALSE(JSONReader::Read("true", &root, false)); 494 ASSERT_FALSE(JSONReader::Read("true", &root, false));
495 ASSERT_FALSE(JSONReader::Read("10", &root, false)); 495 ASSERT_FALSE(JSONReader::Read("10", &root, false));
496 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false)); 496 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false));
497 } 497 }
498 498
OLDNEW
« no previous file with comments | « base/json_reader.cc ('k') | base/string_escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698