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

Side by Side Diff: base/json/json_reader_unittest.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/json_file_value_serializer.cc ('k') | base/process/internal_linux.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 EXPECT_EQ("root", str_val); 540 EXPECT_EQ("root", str_val);
541 } 541 }
542 542
543 TEST(JSONReaderTest, ReadFromFile) { 543 TEST(JSONReaderTest, ReadFromFile) {
544 FilePath path; 544 FilePath path;
545 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &path)); 545 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &path));
546 path = path.AppendASCII("json"); 546 path = path.AppendASCII("json");
547 ASSERT_TRUE(base::PathExists(path)); 547 ASSERT_TRUE(base::PathExists(path));
548 548
549 std::string input; 549 std::string input;
550 ASSERT_TRUE(file_util::ReadFileToString( 550 ASSERT_TRUE(ReadFileToString(
551 path.Append(FILE_PATH_LITERAL("bom_feff.json")), &input)); 551 path.Append(FILE_PATH_LITERAL("bom_feff.json")), &input));
552 552
553 JSONReader reader; 553 JSONReader reader;
554 scoped_ptr<Value> root(reader.ReadToValue(input)); 554 scoped_ptr<Value> root(reader.ReadToValue(input));
555 ASSERT_TRUE(root.get()) << reader.GetErrorMessage(); 555 ASSERT_TRUE(root.get()) << reader.GetErrorMessage();
556 EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); 556 EXPECT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
557 } 557 }
558 558
559 // Tests that the root of a JSON object can be deleted safely while its 559 // Tests that the root of a JSON object can be deleted safely while its
560 // children outlive it. 560 // children outlive it.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 647
648 TEST(JSONReaderTest, IllegalTrailingNull) { 648 TEST(JSONReaderTest, IllegalTrailingNull) {
649 const char json[] = { '"', 'n', 'u', 'l', 'l', '"', '\0' }; 649 const char json[] = { '"', 'n', 'u', 'l', 'l', '"', '\0' };
650 std::string json_string(json, sizeof(json)); 650 std::string json_string(json, sizeof(json));
651 JSONReader reader; 651 JSONReader reader;
652 EXPECT_FALSE(reader.ReadToValue(json_string)); 652 EXPECT_FALSE(reader.ReadToValue(json_string));
653 EXPECT_EQ(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, reader.error_code()); 653 EXPECT_EQ(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, reader.error_code());
654 } 654 }
655 655
656 } // namespace base 656 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_file_value_serializer.cc ('k') | base/process/internal_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698