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

Side by Side Diff: base/json_reader_unittest.cc

Issue 4268: IsStringUTF8 unittest and enforcing UTF-8 in JSON deserialization (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_util.h » ('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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 root = NULL; 474 root = NULL;
475 ASSERT_TRUE(JSONReader::JsonToValue("\"\xe7\xbd\x91\xe9\xa1\xb5\"", &root, 475 ASSERT_TRUE(JSONReader::JsonToValue("\"\xe7\xbd\x91\xe9\xa1\xb5\"", &root,
476 false, false)); 476 false, false));
477 ASSERT_TRUE(root); 477 ASSERT_TRUE(root);
478 ASSERT_TRUE(root->IsType(Value::TYPE_STRING)); 478 ASSERT_TRUE(root->IsType(Value::TYPE_STRING));
479 str_val.clear(); 479 str_val.clear();
480 ASSERT_TRUE(root->GetAsString(&str_val)); 480 ASSERT_TRUE(root->GetAsString(&str_val));
481 ASSERT_EQ(L"\x7f51\x9875", str_val); 481 ASSERT_EQ(L"\x7f51\x9875", str_val);
482 delete root; 482 delete root;
483 483
484 // Test invalid utf8 encoded input
485 root = NULL;
486 ASSERT_FALSE(JSONReader::JsonToValue("\"345\xb0\xa1\xb0\xa2\"", &root,
487 false, false));
488 ASSERT_FALSE(JSONReader::JsonToValue("\"123\xc0\x81\"", &root,
489 false, false));
490
484 // Test invalid root objects. 491 // Test invalid root objects.
485 root = NULL; 492 root = NULL;
486 ASSERT_FALSE(JSONReader::Read("null", &root, false)); 493 ASSERT_FALSE(JSONReader::Read("null", &root, false));
487 ASSERT_FALSE(JSONReader::Read("true", &root, false)); 494 ASSERT_FALSE(JSONReader::Read("true", &root, false));
488 ASSERT_FALSE(JSONReader::Read("10", &root, false)); 495 ASSERT_FALSE(JSONReader::Read("10", &root, false));
489 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false)); 496 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false));
490 } 497 }
491 498
OLDNEW
« no previous file with comments | « base/json_reader.cc ('k') | base/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698