OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/ftp/ftp_util.h" |
| 6 |
| 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 TEST(FtpUtilTest, UnixFilePathToVMS) { |
| 13 const struct { |
| 14 const char* input; |
| 15 const char* expected_output; |
| 16 } kTestCases[] = { |
| 17 { "", "" }, |
| 18 { "/", "[]" }, |
| 19 { "/a", "a" }, |
| 20 { "/a/b", "a:[000000]b" }, |
| 21 { "/a/b/c", "a:[b]c" }, |
| 22 { "/a/b/c/d", "a:[b.c]d" }, |
| 23 { "/a/b/c/d/e", "a:[b.c.d]e" }, |
| 24 { "a", "a" }, |
| 25 { "a/b", "[.a]b" }, |
| 26 { "a/b/c", "[.a.b]c" }, |
| 27 { "a/b/c/d", "[.a.b.c]d" }, |
| 28 }; |
| 29 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 30 EXPECT_EQ(kTestCases[i].expected_output, |
| 31 net::FtpUtil::UnixFilePathToVMS(kTestCases[i].input)) |
| 32 << kTestCases[i].input; |
| 33 } |
| 34 } |
| 35 |
| 36 TEST(FtpUtilTest, UnixDirectoryPathToVMS) { |
| 37 const struct { |
| 38 const char* input; |
| 39 const char* expected_output; |
| 40 } kTestCases[] = { |
| 41 { "", "" }, |
| 42 { "/", "" }, |
| 43 { "/a", "a:[000000]" }, |
| 44 { "/a/", "a:[000000]" }, |
| 45 { "/a/b", "a:[b]" }, |
| 46 { "/a/b/", "a:[b]" }, |
| 47 { "/a/b/c", "a:[b.c]" }, |
| 48 { "/a/b/c/", "a:[b.c]" }, |
| 49 { "/a/b/c/d", "a:[b.c.d]" }, |
| 50 { "/a/b/c/d/", "a:[b.c.d]" }, |
| 51 { "/a/b/c/d/e", "a:[b.c.d.e]" }, |
| 52 { "/a/b/c/d/e/", "a:[b.c.d.e]" }, |
| 53 { "a", "[.a]" }, |
| 54 { "a/", "[.a]" }, |
| 55 { "a/b", "[.a.b]" }, |
| 56 { "a/b/", "[.a.b]" }, |
| 57 { "a/b/c", "[.a.b.c]" }, |
| 58 { "a/b/c/", "[.a.b.c]" }, |
| 59 { "a/b/c/d", "[.a.b.c.d]" }, |
| 60 { "a/b/c/d/", "[.a.b.c.d]" }, |
| 61 }; |
| 62 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 63 EXPECT_EQ(kTestCases[i].expected_output, |
| 64 net::FtpUtil::UnixDirectoryPathToVMS(kTestCases[i].input)) |
| 65 << kTestCases[i].input; |
| 66 } |
| 67 } |
| 68 |
| 69 TEST(FtpUtilTest, VMSPathToUnix) { |
| 70 const struct { |
| 71 const char* input; |
| 72 const char* expected_output; |
| 73 } kTestCases[] = { |
| 74 { "", "." }, |
| 75 { "[]", "/" }, |
| 76 { "a", "/a" }, |
| 77 { "a:[000000]", "/a" }, |
| 78 { "a:[000000]b", "/a/b" }, |
| 79 { "a:[b]", "/a/b" }, |
| 80 { "a:[b]c", "/a/b/c" }, |
| 81 { "a:[b.c]", "/a/b/c" }, |
| 82 { "a:[b.c]d", "/a/b/c/d" }, |
| 83 { "a:[b.c.d]", "/a/b/c/d" }, |
| 84 { "a:[b.c.d]e", "/a/b/c/d/e" }, |
| 85 { "a:[b.c.d.e]", "/a/b/c/d/e" }, |
| 86 { "[.a]", "a" }, |
| 87 { "[.a]b", "a/b" }, |
| 88 { "[.a.b]", "a/b" }, |
| 89 { "[.a.b]c", "a/b/c" }, |
| 90 { "[.a.b.c]", "a/b/c" }, |
| 91 { "[.a.b.c]d", "a/b/c/d" }, |
| 92 { "[.a.b.c.d]", "a/b/c/d" }, |
| 93 }; |
| 94 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { |
| 95 EXPECT_EQ(kTestCases[i].expected_output, |
| 96 net::FtpUtil::VMSPathToUnix(kTestCases[i].input)) |
| 97 << kTestCases[i].input; |
| 98 } |
| 99 } |
| 100 |
| 101 } // namespace |
OLD | NEW |