aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest-filepath_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/gtest-filepath_test.cc')
-rw-r--r--test/gtest-filepath_test.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/gtest-filepath_test.cc b/test/gtest-filepath_test.cc
index f4b70c36..603427c1 100644
--- a/test/gtest-filepath_test.cc
+++ b/test/gtest-filepath_test.cc
@@ -91,6 +91,38 @@ const char* MakeTempDir() {
}
#endif // _WIN32_WCE
+#ifndef _WIN32_WCE
+
+TEST(GetCurrentDirTest, ReturnsCurrentDir) {
+ EXPECT_FALSE(FilePath::GetCurrentDir().IsEmpty());
+
+#ifdef GTEST_OS_WINDOWS
+ _chdir(PATH_SEP);
+ const FilePath cwd = FilePath::GetCurrentDir();
+ // Skips the ":".
+ const char* const cwd_without_drive = strchr(cwd.c_str(), ':');
+ ASSERT_TRUE(cwd_without_drive != NULL);
+ EXPECT_STREQ(PATH_SEP, cwd_without_drive + 1);
+#else
+ chdir(PATH_SEP);
+ EXPECT_STREQ(PATH_SEP, FilePath::GetCurrentDir().c_str());
+#endif
+}
+
+#endif // _WIN32_WCE
+
+TEST(IsEmptyTest, ReturnsTrueForEmptyPath) {
+ EXPECT_TRUE(FilePath("").IsEmpty());
+ EXPECT_TRUE(FilePath(NULL).IsEmpty());
+}
+
+TEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) {
+ EXPECT_FALSE(FilePath("a").IsEmpty());
+ EXPECT_FALSE(FilePath(".").IsEmpty());
+ EXPECT_FALSE(FilePath("a/b").IsEmpty());
+ EXPECT_FALSE(FilePath("a\\b\\").IsEmpty());
+}
+
// FilePath's functions used by UnitTestOptions::GetOutputFile.
// RemoveDirectoryName "" -> ""