OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "tools/gn/filesystem_utils.h" | 9 #include "tools/gn/filesystem_utils.h" |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 std::string input; | 66 std::string input; |
67 EXPECT_EQ("", FindDir(&input)); | 67 EXPECT_EQ("", FindDir(&input)); |
68 input = "/"; | 68 input = "/"; |
69 EXPECT_EQ("/", FindDir(&input)); | 69 EXPECT_EQ("/", FindDir(&input)); |
70 input = "foo/"; | 70 input = "foo/"; |
71 EXPECT_EQ("foo/", FindDir(&input)); | 71 EXPECT_EQ("foo/", FindDir(&input)); |
72 input = "foo/bar/baz"; | 72 input = "foo/bar/baz"; |
73 EXPECT_EQ("foo/bar/", FindDir(&input)); | 73 EXPECT_EQ("foo/bar/", FindDir(&input)); |
74 } | 74 } |
75 | 75 |
| 76 TEST(FilesystemUtils, FindLastDirComponent) { |
| 77 SourceDir empty; |
| 78 EXPECT_EQ("", FindLastDirComponent(empty)); |
| 79 |
| 80 SourceDir root("/"); |
| 81 EXPECT_EQ("", FindLastDirComponent(root)); |
| 82 |
| 83 SourceDir srcroot("//"); |
| 84 EXPECT_EQ("", FindLastDirComponent(srcroot)); |
| 85 |
| 86 SourceDir regular1("//foo/"); |
| 87 EXPECT_EQ("foo", FindLastDirComponent(regular1)); |
| 88 |
| 89 SourceDir regular2("//foo/bar/"); |
| 90 EXPECT_EQ("bar", FindLastDirComponent(regular2)); |
| 91 } |
| 92 |
76 TEST(FilesystemUtils, IsPathAbsolute) { | 93 TEST(FilesystemUtils, IsPathAbsolute) { |
77 EXPECT_TRUE(IsPathAbsolute("/foo/bar")); | 94 EXPECT_TRUE(IsPathAbsolute("/foo/bar")); |
78 EXPECT_TRUE(IsPathAbsolute("/")); | 95 EXPECT_TRUE(IsPathAbsolute("/")); |
79 EXPECT_FALSE(IsPathAbsolute("")); | 96 EXPECT_FALSE(IsPathAbsolute("")); |
80 EXPECT_FALSE(IsPathAbsolute("//")); | 97 EXPECT_FALSE(IsPathAbsolute("//")); |
81 EXPECT_FALSE(IsPathAbsolute("//foo/bar")); | 98 EXPECT_FALSE(IsPathAbsolute("//foo/bar")); |
82 | 99 |
83 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
84 EXPECT_TRUE(IsPathAbsolute("C:/foo")); | 101 EXPECT_TRUE(IsPathAbsolute("C:/foo")); |
85 EXPECT_TRUE(IsPathAbsolute("C:/")); | 102 EXPECT_TRUE(IsPathAbsolute("C:/")); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 build_settings.SetBuildDir(SourceDir("//")); | 392 build_settings.SetBuildDir(SourceDir("//")); |
376 Settings settings(&build_settings, ""); | 393 Settings settings(&build_settings, ""); |
377 | 394 |
378 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value()); | 395 EXPECT_EQ("//", GetToolchainOutputDir(&settings).value()); |
379 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value()); | 396 EXPECT_EQ("//gen/", GetToolchainGenDir(&settings).value()); |
380 EXPECT_EQ("//obj/", | 397 EXPECT_EQ("//obj/", |
381 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); | 398 GetOutputDirForSourceDir(&settings, SourceDir("//")).value()); |
382 EXPECT_EQ("//gen/", | 399 EXPECT_EQ("//gen/", |
383 GetGenDirForSourceDir(&settings, SourceDir("//")).value()); | 400 GetGenDirForSourceDir(&settings, SourceDir("//")).value()); |
384 } | 401 } |
OLD | NEW |