From 019d19af978f05b774407e0d46a3bda2c18c67c6 Mon Sep 17 00:00:00 2001 From: shiqian Date: Fri, 12 Sep 2008 04:01:37 +0000 Subject: Improves thread-safe death tests by changing to the original working directory before they are executed; also fixes out-dated comments about death tests. --- test/gtest-filepath_test.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/gtest-filepath_test.cc') 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 "" -> "" -- cgit v1.2.3