aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest-filepath_test.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-03-26 19:03:47 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-03-26 19:03:47 +0000
commit3c7bbf5b46679aea4e0ac7d3ad241cb036146751 (patch)
treef452879c8f86232be2dec970ec7bce3a9963ed49 /test/gtest-filepath_test.cc
parentf3c6efd8d78f96a9a500b3ba7e024de122b9afa1 (diff)
downloadgoogletest-3c7bbf5b46679aea4e0ac7d3ad241cb036146751.tar.gz
googletest-3c7bbf5b46679aea4e0ac7d3ad241cb036146751.tar.bz2
googletest-3c7bbf5b46679aea4e0ac7d3ad241cb036146751.zip
Simplifies implementation by defining a POSIX portability layer; adds the death test style flag to --help.
Diffstat (limited to 'test/gtest-filepath_test.cc')
-rw-r--r--test/gtest-filepath_test.cc42
1 files changed, 9 insertions, 33 deletions
diff --git a/test/gtest-filepath_test.cc b/test/gtest-filepath_test.cc
index f8b68a78..77a2988e 100644
--- a/test/gtest-filepath_test.cc
+++ b/test/gtest-filepath_test.cc
@@ -86,18 +86,17 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
const FilePath original_dir = FilePath::GetCurrentDir();
EXPECT_FALSE(original_dir.IsEmpty());
-#if GTEST_OS_WINDOWS
- _chdir(GTEST_PATH_SEP_);
+ posix::chdir(GTEST_PATH_SEP_);
const FilePath cwd = FilePath::GetCurrentDir();
- _chdir(original_dir.c_str());
+ posix::chdir(original_dir.c_str());
+
+#if GTEST_OS_WINDOWS
// Skips the ":".
const char* const cwd_without_drive = strchr(cwd.c_str(), ':');
ASSERT_TRUE(cwd_without_drive != NULL);
EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);
#else
- chdir(GTEST_PATH_SEP_);
- EXPECT_STREQ(GTEST_PATH_SEP_, FilePath::GetCurrentDir().c_str());
- chdir(original_dir.c_str());
+ EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str());
#endif
}
@@ -436,22 +435,14 @@ class DirectoryCreationTest : public Test {
remove(testdata_file_.c_str());
remove(unique_file0_.c_str());
remove(unique_file1_.c_str());
-#if GTEST_OS_WINDOWS
- _rmdir(testdata_path_.c_str());
-#else
- rmdir(testdata_path_.c_str());
-#endif // GTEST_OS_WINDOWS
+ posix::rmdir(testdata_path_.c_str());
}
virtual void TearDown() {
remove(testdata_file_.c_str());
remove(unique_file0_.c_str());
remove(unique_file1_.c_str());
-#if GTEST_OS_WINDOWS
- _rmdir(testdata_path_.c_str());
-#else
- rmdir(testdata_path_.c_str());
-#endif // GTEST_OS_WINDOWS
+ posix::rmdir(testdata_path_.c_str());
}
String TempDir() const {
@@ -459,13 +450,7 @@ class DirectoryCreationTest : public Test {
return String("\\temp\\");
#elif GTEST_OS_WINDOWS
- // MSVC 8 deprecates getenv(), so we want to suppress warning 4996
- // (deprecated function) there.
-#pragma warning(push) // Saves the current warning state.
-#pragma warning(disable:4996) // Temporarily disables warning 4996.
- const char* temp_dir = getenv("TEMP");
-#pragma warning(pop) // Restores the warning state.
-
+ const char* temp_dir = posix::getenv("TEMP");
if (temp_dir == NULL || temp_dir[0] == '\0')
return String("\\temp\\");
else if (String(temp_dir).EndsWith("\\"))
@@ -478,16 +463,7 @@ class DirectoryCreationTest : public Test {
}
void CreateTextFile(const char* filename) {
-#if GTEST_OS_WINDOWS
- // MSVC 8 deprecates fopen(), so we want to suppress warning 4996
- // (deprecated function) there.#pragma warning(push)
-#pragma warning(push) // Saves the current warning state.
-#pragma warning(disable:4996) // Temporarily disables warning 4996.
- FILE* f = fopen(filename, "w");
-#pragma warning(pop) // Restores the warning state.
-#else // We are on Linux or Mac OS.
- FILE* f = fopen(filename, "w");
-#endif // GTEST_OS_WINDOWS
+ FILE* f = posix::fopen(filename, "w");
fprintf(f, "text\n");
fclose(f);
}