This source file includes following definitions.
- TEST
- TEST
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/source_dir.h"
#include "tools/gn/source_file.h"
TEST(SourceDir, ResolveRelativeFile) {
SourceDir base("//base/");
EXPECT_TRUE(base.ResolveRelativeFile("") == SourceFile());
EXPECT_TRUE(base.ResolveRelativeFile("//foo/bar/") == SourceFile());
EXPECT_TRUE(base.ResolveRelativeFile("bar/") == SourceFile());
EXPECT_TRUE(base.ResolveRelativeFile("//foo") == SourceFile("//foo"));
EXPECT_TRUE(base.ResolveRelativeFile("/foo") == SourceFile("/foo"));
EXPECT_TRUE(base.ResolveRelativeFile("foo") == SourceFile("//base/foo"));
EXPECT_TRUE(base.ResolveRelativeFile("./foo") == SourceFile("//base/foo"));
EXPECT_TRUE(base.ResolveRelativeFile("../foo") == SourceFile("//foo"));
EXPECT_TRUE(base.ResolveRelativeFile("../../foo") == SourceFile("//foo"));
#if defined(OS_WIN)
EXPECT_TRUE(base.ResolveRelativeFile("C:\\foo\\bar.txt") ==
SourceFile("/C:/foo/bar.txt"));
#endif
}
TEST(SourceDir, ResolveRelativeDir) {
SourceDir base("//base/");
EXPECT_TRUE(base.ResolveRelativeDir("") == SourceDir());
EXPECT_TRUE(base.ResolveRelativeDir("//foo") == SourceDir("//foo/"));
EXPECT_TRUE(base.ResolveRelativeDir("/foo") == SourceDir("/foo/"));
EXPECT_TRUE(base.ResolveRelativeDir("foo") == SourceDir("//base/foo/"));
EXPECT_TRUE(base.ResolveRelativeDir("./foo") == SourceDir("//base/foo/"));
EXPECT_TRUE(base.ResolveRelativeDir("../foo") == SourceDir("//foo/"));
EXPECT_TRUE(base.ResolveRelativeDir("../../foo/") == SourceDir("//foo/"));
#if defined(OS_WIN)
EXPECT_TRUE(base.ResolveRelativeDir("C:\\foo") == SourceDir("/C:/foo/"));
#endif
}