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

Side by Side Diff: net/ftp/ftp_util_unittest.cc

Issue 2610973002: Fix a pair of bugs in UNIX->VMS path conversion. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/ftp/ftp_util.h" 5 #include "net/ftp/ftp_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 16 matching lines...) Expand all
27 { "/", "[]" }, 27 { "/", "[]" },
28 { "/a", "a" }, 28 { "/a", "a" },
29 { "/a/b", "a:[000000]b" }, 29 { "/a/b", "a:[000000]b" },
30 { "/a/b/c", "a:[b]c" }, 30 { "/a/b/c", "a:[b]c" },
31 { "/a/b/c/d", "a:[b.c]d" }, 31 { "/a/b/c/d", "a:[b.c]d" },
32 { "/a/b/c/d/e", "a:[b.c.d]e" }, 32 { "/a/b/c/d/e", "a:[b.c.d]e" },
33 { "a", "a" }, 33 { "a", "a" },
34 { "a/b", "[.a]b" }, 34 { "a/b", "[.a]b" },
35 { "a/b/c", "[.a.b]c" }, 35 { "a/b/c", "[.a.b]c" },
36 { "a/b/c/d", "[.a.b.c]d" }, 36 { "a/b/c/d", "[.a.b.c]d" },
37 // Extra slashes shouldn't matter.
38 { "/////", "[]" },
39 { "/////a", "a" },
40 { "//a//b///c", "a:[b]c" },
41 { "a//b///c", "[.a.b]c" },
37 }; 42 };
38 for (size_t i = 0; i < arraysize(kTestCases); i++) { 43 for (size_t i = 0; i < arraysize(kTestCases); i++) {
39 EXPECT_EQ(kTestCases[i].expected_output, 44 EXPECT_EQ(kTestCases[i].expected_output,
40 FtpUtil::UnixFilePathToVMS(kTestCases[i].input)) 45 FtpUtil::UnixFilePathToVMS(kTestCases[i].input))
41 << kTestCases[i].input; 46 << kTestCases[i].input;
42 } 47 }
43 } 48 }
44 49
45 TEST(FtpUtilTest, UnixDirectoryPathToVMS) { 50 TEST(FtpUtilTest, UnixDirectoryPathToVMS) {
46 const struct { 51 const struct {
47 const char* input; 52 const char* input;
48 const char* expected_output; 53 const char* expected_output;
49 } kTestCases[] = { 54 } kTestCases[] = {
50 { "", "" }, 55 { "", "" },
51 { "/", "" }, 56 { "/", "" },
52 { "/a", "a:[000000]" }, 57 { "/a", "a:[000000]" },
53 { "/a/", "a:[000000]" }, 58 { "/a/", "a:[000000]" },
54 { "/a/b", "a:[b]" }, 59 { "/a/b", "a:[b]" },
55 { "/a/b/", "a:[b]" }, 60 { "/a/b/", "a:[b]" },
56 { "/a/b/c", "a:[b.c]" }, 61 { "/a/b/c", "a:[b.c]" },
57 { "/a/b/c/", "a:[b.c]" }, 62 { "/a/b/c/", "a:[b.c]" },
58 { "/a/b/c/d", "a:[b.c.d]" }, 63 { "/a/b/c/d", "a:[b.c.d]" },
59 { "/a/b/c/d/", "a:[b.c.d]" }, 64 { "/a/b/c/d/", "a:[b.c.d]" },
60 { "/a/b/c/d/e", "a:[b.c.d.e]" }, 65 { "/a/b/c/d/e", "a:[b.c.d.e]" },
61 { "/a/b/c/d/e/", "a:[b.c.d.e]" }, 66 { "/a/b/c/d/e/", "a:[b.c.d.e]" },
62 { "a", "[.a]" }, 67 { "a", "[.a]" },
63 { "a/", "[.a]" }, 68 { "a/", "[.a]" },
64 { "a/b", "[.a.b]" }, 69 { "a/b", "[.a.b]" },
65 { "a/b/", "[.a.b]" }, 70 { "a/b/", "[.a.b]" },
66 { "a/b/c", "[.a.b.c]" }, 71 { "a/b/c", "[.a.b.c]" },
67 { "a/b/c/", "[.a.b.c]" }, 72 { "a/b/c/", "[.a.b.c]" },
68 { "a/b/c/d", "[.a.b.c.d]" }, 73 { "a/b/c/d", "[.a.b.c.d]" },
69 { "a/b/c/d/", "[.a.b.c.d]" }, 74 { "a/b/c/d/", "[.a.b.c.d]" },
75 // Extra slashes shouldn't matter.
76 { "/////", "" },
77 { "//a//b///c//", "a:[b.c]" },
78 { "a//b///c//", "[.a.b.c]" },
70 }; 79 };
71 for (size_t i = 0; i < arraysize(kTestCases); i++) { 80 for (size_t i = 0; i < arraysize(kTestCases); i++) {
72 EXPECT_EQ(kTestCases[i].expected_output, 81 EXPECT_EQ(kTestCases[i].expected_output,
73 FtpUtil::UnixDirectoryPathToVMS(kTestCases[i].input)) 82 FtpUtil::UnixDirectoryPathToVMS(kTestCases[i].input))
74 << kTestCases[i].input; 83 << kTestCases[i].input;
75 } 84 }
76 } 85 }
77 86
78 TEST(FtpUtilTest, VMSPathToUnix) { 87 TEST(FtpUtilTest, VMSPathToUnix) {
79 const struct { 88 const struct {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 258
250 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), 259 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result),
251 FtpUtil::GetStringPartAfterColumns( 260 FtpUtil::GetStringPartAfterColumns(
252 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); 261 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column));
253 } 262 }
254 } 263 }
255 264
256 } // namespace 265 } // namespace
257 266
258 } // namespace net 267 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698