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

Side by Side Diff: base/file_util_unittest.cc

Issue 147220: Use platform-appropriate newlines in JSON output (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/file_util.cc ('k') | base/json_reader_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) 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 EXPECT_FALSE(file_util::ContentsEqual(L"bogusname", L"bogusname")); 622 EXPECT_FALSE(file_util::ContentsEqual(L"bogusname", L"bogusname"));
623 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_first_file)); 623 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_first_file));
624 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_last_file)); 624 EXPECT_FALSE(file_util::ContentsEqual(original_file, different_last_file));
625 EXPECT_TRUE(file_util::ContentsEqual(empty1_file, empty2_file)); 625 EXPECT_TRUE(file_util::ContentsEqual(empty1_file, empty2_file));
626 EXPECT_FALSE(file_util::ContentsEqual(original_file, shortened_file)); 626 EXPECT_FALSE(file_util::ContentsEqual(original_file, shortened_file));
627 EXPECT_FALSE(file_util::ContentsEqual(shortened_file, original_file)); 627 EXPECT_FALSE(file_util::ContentsEqual(shortened_file, original_file));
628 EXPECT_TRUE(file_util::ContentsEqual(binary_file, binary_file_same)); 628 EXPECT_TRUE(file_util::ContentsEqual(binary_file, binary_file_same));
629 EXPECT_FALSE(file_util::ContentsEqual(binary_file, binary_file_diff)); 629 EXPECT_FALSE(file_util::ContentsEqual(binary_file, binary_file_diff));
630 } 630 }
631 631
632 TEST_F(ReadOnlyFileUtilTest, TextContentsEqual) {
633 FilePath data_dir;
634 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir));
635 data_dir = data_dir.Append(FILE_PATH_LITERAL("base"))
636 .Append(FILE_PATH_LITERAL("data"))
637 .Append(FILE_PATH_LITERAL("file_util_unittest"));
638 ASSERT_TRUE(file_util::PathExists(data_dir));
639
640 FilePath original_file =
641 data_dir.Append(FILE_PATH_LITERAL("original.txt"));
642 FilePath same_file =
643 data_dir.Append(FILE_PATH_LITERAL("same.txt"));
644 FilePath crlf_file =
645 data_dir.Append(FILE_PATH_LITERAL("crlf.txt"));
646 FilePath shortened_file =
647 data_dir.Append(FILE_PATH_LITERAL("shortened.txt"));
648 FilePath different_file =
649 data_dir.Append(FILE_PATH_LITERAL("different.txt"));
650 FilePath different_first_file =
651 data_dir.Append(FILE_PATH_LITERAL("different_first.txt"));
652 FilePath different_last_file =
653 data_dir.Append(FILE_PATH_LITERAL("different_last.txt"));
654 FilePath first1_file =
655 data_dir.Append(FILE_PATH_LITERAL("first1.txt"));
656 FilePath first2_file =
657 data_dir.Append(FILE_PATH_LITERAL("first2.txt"));
658 FilePath empty1_file =
659 data_dir.Append(FILE_PATH_LITERAL("empty1.txt"));
660 FilePath empty2_file =
661 data_dir.Append(FILE_PATH_LITERAL("empty2.txt"));
662 FilePath blank_line_file =
663 data_dir.Append(FILE_PATH_LITERAL("blank_line.txt"));
664 FilePath blank_line_crlf_file =
665 data_dir.Append(FILE_PATH_LITERAL("blank_line_crlf.txt"));
666
667 EXPECT_TRUE(file_util::TextContentsEqual(original_file, same_file));
668 EXPECT_TRUE(file_util::TextContentsEqual(original_file, crlf_file));
669 EXPECT_FALSE(file_util::TextContentsEqual(original_file, shortened_file));
670 EXPECT_FALSE(file_util::TextContentsEqual(original_file, different_file));
671 EXPECT_FALSE(file_util::TextContentsEqual(original_file,
672 different_first_file));
673 EXPECT_FALSE(file_util::TextContentsEqual(original_file,
674 different_last_file));
675 EXPECT_FALSE(file_util::TextContentsEqual(first1_file, first2_file));
676 EXPECT_TRUE(file_util::TextContentsEqual(empty1_file, empty2_file));
677 EXPECT_FALSE(file_util::TextContentsEqual(original_file, empty1_file));
678 EXPECT_TRUE(file_util::TextContentsEqual(blank_line_file,
679 blank_line_crlf_file));
680 }
681
632 // We don't need equivalent functionality outside of Windows. 682 // We don't need equivalent functionality outside of Windows.
633 #if defined(OS_WIN) 683 #if defined(OS_WIN)
634 TEST_F(FileUtilTest, ResolveShortcutTest) { 684 TEST_F(FileUtilTest, ResolveShortcutTest) {
635 FilePath target_file = test_dir_.Append(L"Target.txt"); 685 FilePath target_file = test_dir_.Append(L"Target.txt");
636 CreateTextFile(target_file, L"This is the target."); 686 CreateTextFile(target_file, L"This is the target.");
637 687
638 FilePath link_file = test_dir_.Append(L"Link.lnk"); 688 FilePath link_file = test_dir_.Append(L"Link.lnk");
639 689
640 HRESULT result; 690 HRESULT result;
641 IShellLink *shell = NULL; 691 IShellLink *shell = NULL;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 #elif defined(OS_LINUX) 1159 #elif defined(OS_LINUX)
1110 EXPECT_FALSE(file_util::ContainsPath(foo, 1160 EXPECT_FALSE(file_util::ContainsPath(foo,
1111 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); 1161 foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
1112 #else 1162 #else
1113 // We can't really do this test on osx since the case-sensitivity of the 1163 // We can't really do this test on osx since the case-sensitivity of the
1114 // filesystem is configurable. 1164 // filesystem is configurable.
1115 #endif 1165 #endif
1116 } 1166 }
1117 1167
1118 } // namespace 1168 } // namespace
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698