aboutsummaryrefslogtreecommitdiff
path: root/googletest/test/googletest-options-test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/test/googletest-options-test.cc')
-rw-r--r--googletest/test/googletest-options-test.cc87
1 files changed, 46 insertions, 41 deletions
diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc
index c09d5723..722c5b55 100644
--- a/googletest/test/googletest-options-test.cc
+++ b/googletest/test/googletest-options-test.cc
@@ -36,13 +36,15 @@
// make-files on Windows and other platforms. Do not #include this file
// anywhere else!
+#include <string>
+
#include "gtest/gtest.h"
-#if GTEST_OS_WINDOWS_MOBILE
-# include <windows.h>
-#elif GTEST_OS_WINDOWS
-# include <direct.h>
-#elif GTEST_OS_OS2
+#ifdef GTEST_OS_WINDOWS_MOBILE
+#include <windows.h>
+#elif defined(GTEST_OS_WINDOWS)
+#include <direct.h>
+#elif defined(GTEST_OS_OS2)
// For strcasecmp on OS/2
#include <strings.h>
#endif // GTEST_OS_WINDOWS_MOBILE
@@ -61,36 +63,36 @@ FilePath GetAbsolutePathOf(const FilePath& relative_path) {
// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.
TEST(XmlOutputTest, GetOutputFormatDefault) {
- GTEST_FLAG(output) = "";
+ GTEST_FLAG_SET(output, "");
EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str());
}
TEST(XmlOutputTest, GetOutputFormat) {
- GTEST_FLAG(output) = "xml:filename";
+ GTEST_FLAG_SET(output, "xml:filename");
EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str());
}
TEST(XmlOutputTest, GetOutputFileDefault) {
- GTEST_FLAG(output) = "";
+ GTEST_FLAG_SET(output, "");
EXPECT_EQ(GetAbsolutePathOf(FilePath("test_detail.xml")).string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
}
TEST(XmlOutputTest, GetOutputFileSingleFile) {
- GTEST_FLAG(output) = "xml:filename.abc";
+ GTEST_FLAG_SET(output, "xml:filename.abc");
EXPECT_EQ(GetAbsolutePathOf(FilePath("filename.abc")).string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
}
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
- GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
+ GTEST_FLAG_SET(output, "xml:path" GTEST_PATH_SEP_);
const std::string expected_output_file =
- GetAbsolutePathOf(
- FilePath(std::string("path") + GTEST_PATH_SEP_ +
- GetCurrentExecutableName().string() + ".xml")).string();
+ GetAbsolutePathOf(FilePath(std::string("path") + GTEST_PATH_SEP_ +
+ GetCurrentExecutableName().string() + ".xml"))
+ .string();
const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile();
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());
@@ -99,19 +101,19 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
const std::string exe_str = GetCurrentExecutableName().string();
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
const bool success =
_strcmpi("googletest-options-test", exe_str.c_str()) == 0 ||
_strcmpi("gtest-options-ex_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_all_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_dll_test", exe_str.c_str()) == 0;
-#elif GTEST_OS_OS2
+#elif defined(GTEST_OS_OS2)
const bool success =
strcasecmp("googletest-options-test", exe_str.c_str()) == 0 ||
strcasecmp("gtest-options-ex_test", exe_str.c_str()) == 0 ||
strcasecmp("gtest_all_test", exe_str.c_str()) == 0 ||
strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
-#elif GTEST_OS_FUCHSIA
+#elif defined(GTEST_OS_FUCHSIA)
const bool success = exe_str == "app";
#else
const bool success =
@@ -126,11 +128,10 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
#endif
;
#endif // GTEST_OS_WINDOWS
- if (!success)
- FAIL() << "GetCurrentExecutableName() returns " << exe_str;
+ if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
}
-#if !GTEST_OS_FUCHSIA
+#ifndef GTEST_OS_FUCHSIA
class XmlOutputChangeDirTest : public Test {
protected:
@@ -150,36 +151,40 @@ class XmlOutputChangeDirTest : public Test {
};
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {
- GTEST_FLAG(output) = "";
- EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
- FilePath("test_detail.xml")).string(),
- UnitTestOptions::GetAbsolutePathToOutputFile());
+ GTEST_FLAG_SET(output, "");
+ EXPECT_EQ(
+ FilePath::ConcatPaths(original_working_dir_, FilePath("test_detail.xml"))
+ .string(),
+ UnitTestOptions::GetAbsolutePathToOutputFile());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {
- GTEST_FLAG(output) = "xml";
- EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
- FilePath("test_detail.xml")).string(),
- UnitTestOptions::GetAbsolutePathToOutputFile());
+ GTEST_FLAG_SET(output, "xml");
+ EXPECT_EQ(
+ FilePath::ConcatPaths(original_working_dir_, FilePath("test_detail.xml"))
+ .string(),
+ UnitTestOptions::GetAbsolutePathToOutputFile());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
- GTEST_FLAG(output) = "xml:filename.abc";
- EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,
- FilePath("filename.abc")).string(),
- UnitTestOptions::GetAbsolutePathToOutputFile());
+ GTEST_FLAG_SET(output, "xml:filename.abc");
+ EXPECT_EQ(
+ FilePath::ConcatPaths(original_working_dir_, FilePath("filename.abc"))
+ .string(),
+ UnitTestOptions::GetAbsolutePathToOutputFile());
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
- GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
+ GTEST_FLAG_SET(output, "xml:path" GTEST_PATH_SEP_);
const std::string expected_output_file =
FilePath::ConcatPaths(
original_working_dir_,
FilePath(std::string("path") + GTEST_PATH_SEP_ +
- GetCurrentExecutableName().string() + ".xml")).string();
+ GetCurrentExecutableName().string() + ".xml"))
+ .string();
const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile();
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());
@@ -187,31 +192,31 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
-#if GTEST_OS_WINDOWS
- GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc";
+#ifdef GTEST_OS_WINDOWS
+ GTEST_FLAG_SET(output, "xml:c:\\tmp\\filename.abc");
EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
#else
- GTEST_FLAG(output) ="xml:/tmp/filename.abc";
+ GTEST_FLAG_SET(output, "xml:/tmp/filename.abc");
EXPECT_EQ(FilePath("/tmp/filename.abc").string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
#endif
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
const std::string path = "c:\\tmp\\";
#else
const std::string path = "/tmp/";
#endif
- GTEST_FLAG(output) = "xml:" + path;
+ GTEST_FLAG_SET(output, "xml:" + path);
const std::string expected_output_file =
path + GetCurrentExecutableName().string() + ".xml";
const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile();
-#if GTEST_OS_WINDOWS
+#ifdef GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else
EXPECT_EQ(expected_output_file, output_file.c_str());