Correct blacklist entry message
[chromium-blink-merge.git] / tools / gn / source_dir_unittest.cc
blob6b3b6d2ca64096f3f3e90c076f49c70e9e7f3897
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
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/source_dir.h"
7 #include "tools/gn/source_file.h"
9 TEST(SourceDir, ResolveRelativeFile) {
10 SourceDir base("//base/");
12 // Empty input is an error.
13 EXPECT_TRUE(base.ResolveRelativeFile("") == SourceFile());
15 // These things are directories, so should be an error.
16 EXPECT_TRUE(base.ResolveRelativeFile("//foo/bar/") == SourceFile());
17 EXPECT_TRUE(base.ResolveRelativeFile("bar/") == SourceFile());
19 // Absolute paths should be passed unchanged.
20 EXPECT_TRUE(base.ResolveRelativeFile("//foo") == SourceFile("//foo"));
21 EXPECT_TRUE(base.ResolveRelativeFile("/foo") == SourceFile("/foo"));
23 // Basic relative stuff.
24 EXPECT_TRUE(base.ResolveRelativeFile("foo") == SourceFile("//base/foo"));
25 EXPECT_TRUE(base.ResolveRelativeFile("./foo") == SourceFile("//base/foo"));
26 EXPECT_TRUE(base.ResolveRelativeFile("../foo") == SourceFile("//foo"));
27 EXPECT_TRUE(base.ResolveRelativeFile("../../foo") == SourceFile("//foo"));
29 #if defined(OS_WIN)
30 // Note that we don't canonicalize the backslashes to forward slashes.
31 // This could potentially be changed in the future which would mean we should
32 // just change the expected result.
33 EXPECT_TRUE(base.ResolveRelativeFile("C:\\foo\\bar.txt") ==
34 SourceFile("/C:\\foo\\bar.txt"));
35 #endif
38 TEST(SourceDir, ResolveRelativeDir) {
39 SourceDir base("//base/");
41 // Empty input is an error.
42 EXPECT_TRUE(base.ResolveRelativeDir("") == SourceDir());
44 // Absolute paths should be passed unchanged.
45 EXPECT_TRUE(base.ResolveRelativeDir("//foo") == SourceDir("//foo/"));
46 EXPECT_TRUE(base.ResolveRelativeDir("/foo") == SourceDir("/foo/"));
48 // Basic relative stuff.
49 EXPECT_TRUE(base.ResolveRelativeDir("foo") == SourceDir("//base/foo/"));
50 EXPECT_TRUE(base.ResolveRelativeDir("./foo") == SourceDir("//base/foo/"));
51 EXPECT_TRUE(base.ResolveRelativeDir("../foo") == SourceDir("//foo/"));
52 EXPECT_TRUE(base.ResolveRelativeDir("../../foo/") == SourceDir("//foo/"));
54 #if defined(OS_WIN)
55 // Note that we don't canonicalize the existing backslashes to forward
56 // slashes. This could potentially be changed in the future which would mean
57 // we should just change the expected result.
58 EXPECT_TRUE(base.ResolveRelativeDir("C:\\foo") == SourceDir("/C:\\foo/"));
59 #endif