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

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

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/json/json_value_serializer_unittest.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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 root.reset(JSONReader::Read("\"root\"")); 537 root.reset(JSONReader::Read("\"root\""));
538 ASSERT_TRUE(root.get()); 538 ASSERT_TRUE(root.get());
539 EXPECT_TRUE(root->GetAsString(&str_val)); 539 EXPECT_TRUE(root->GetAsString(&str_val));
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(file_util::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(file_util::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 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 651
652 TEST(JSONReaderTest, IllegalTrailingNull) { 652 TEST(JSONReaderTest, IllegalTrailingNull) {
653 const char json[] = { '"', 'n', 'u', 'l', 'l', '"', '\0' }; 653 const char json[] = { '"', 'n', 'u', 'l', 'l', '"', '\0' };
654 std::string json_string(json, sizeof(json)); 654 std::string json_string(json, sizeof(json));
655 JSONReader reader; 655 JSONReader reader;
656 EXPECT_FALSE(reader.ReadToValue(json_string)); 656 EXPECT_FALSE(reader.ReadToValue(json_string));
657 EXPECT_EQ(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, reader.error_code()); 657 EXPECT_EQ(JSONReader::JSON_UNEXPECTED_DATA_AFTER_ROOT, reader.error_code());
658 } 658 }
659 659
660 } // namespace base 660 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_file_value_serializer.cc ('k') | base/json/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698