aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest-filepath_test.cc
diff options
context:
space:
mode:
authorshiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-09-12 04:01:37 +0000
committershiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2008-09-12 04:01:37 +0000
commit019d19af978f05b774407e0d46a3bda2c18c67c6 (patch)
tree8522f2db6e168ee4e829c2e7f2cf6dfbaaab30c7 /test/gtest-filepath_test.cc
parent29d8235540f1983c3dbd53a23783530017be80e7 (diff)
downloadgoogletest-019d19af978f05b774407e0d46a3bda2c18c67c6.tar.gz
googletest-019d19af978f05b774407e0d46a3bda2c18c67c6.tar.bz2
googletest-019d19af978f05b774407e0d46a3bda2c18c67c6.zip
Improves thread-safe death tests by changing to the original working directory before they are executed; also fixes out-dated comments about death tests.
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 "" -> ""