summaryrefslogtreecommitdiffstats
path: root/gtest/test/gtest-options_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtest/test/gtest-options_test.cc')
-rw-r--r--gtest/test/gtest-options_test.cc139
1 files changed, 97 insertions, 42 deletions
diff --git a/gtest/test/gtest-options_test.cc b/gtest/test/gtest-options_test.cc
index 2e2cbc9..31ae327 100644
--- a/gtest/test/gtest-options_test.cc
+++ b/gtest/test/gtest-options_test.cc
@@ -89,38 +89,61 @@ TEST(XmlOutputTest, GetOutputFileSingleFile) {
}
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
- GTEST_FLAG(output) = "xml:path" GTEST_PATH_SEP_;
- const std::string expected_output_file =
- GetAbsolutePathOf(
- FilePath(std::string("path") + GTEST_PATH_SEP_ +
- GetCurrentExecutableName().c_str() + ".xml")).c_str();
- const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS
- EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
+ GTEST_FLAG(output) = "xml:path\\";
+ const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
+ EXPECT_TRUE(
+ _strcmpi(output_file.c_str(),
+ GetAbsolutePathOf(
+ FilePath("path\\gtest-options_test.xml")).c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ GetAbsolutePathOf(
+ FilePath("path\\gtest-options-ex_test.xml")).c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ GetAbsolutePathOf(
+ FilePath("path\\gtest_all_test.xml")).c_str()) == 0)
+ << " output_file = " << output_file;
#else
- EXPECT_EQ(expected_output_file, output_file.c_str());
+ GTEST_FLAG(output) = "xml:path/";
+ const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
+ // TODO(wan@google.com): libtool causes the test binary file to be
+ // named lt-gtest-options_test. Therefore the output file may be
+ // named .../lt-gtest-options_test.xml. We should remove this
+ // hard-coded logic when Chandler Carruth's libtool replacement is
+ // ready.
+ EXPECT_TRUE(output_file ==
+ GetAbsolutePathOf(
+ FilePath("path/gtest-options_test.xml")).c_str() ||
+ output_file ==
+ GetAbsolutePathOf(
+ FilePath("path/lt-gtest-options_test.xml")).c_str() ||
+ output_file ==
+ GetAbsolutePathOf(
+ FilePath("path/gtest_all_test.xml")).c_str() ||
+ output_file ==
+ GetAbsolutePathOf(
+ FilePath("path/lt-gtest_all_test.xml")).c_str())
+ << " output_file = " << output_file;
#endif
}
TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
- const std::string exe_str = GetCurrentExecutableName().c_str();
+ const FilePath executable = GetCurrentExecutableName();
+ const char* const exe_str = executable.c_str();
#if GTEST_OS_WINDOWS
- const bool success =
- _strcmpi("gtest-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;
+ ASSERT_TRUE(_strcmpi("gtest-options_test", exe_str) == 0 ||
+ _strcmpi("gtest-options-ex_test", exe_str) == 0 ||
+ _strcmpi("gtest_all_test", exe_str) == 0)
+ << "GetCurrentExecutableName() returns " << exe_str;
#else
// TODO(wan@google.com): remove the hard-coded "lt-" prefix when
// Chandler Carruth's libtool replacement is ready.
- const bool success =
- exe_str == "gtest-options_test" ||
- exe_str == "gtest_all_test" ||
- exe_str == "lt-gtest_all_test" ||
- exe_str == "gtest_dll_test";
+ EXPECT_TRUE(String(exe_str) == "gtest-options_test" ||
+ String(exe_str) == "lt-gtest-options_test" ||
+ String(exe_str) == "gtest_all_test" ||
+ String(exe_str) == "lt-gtest_all_test")
+ << "GetCurrentExecutableName() returns " << exe_str;
#endif // GTEST_OS_WINDOWS
- if (!success)
- FAIL() << "GetCurrentExecutableName() returns " << exe_str;
}
class XmlOutputChangeDirTest : public Test {
@@ -162,17 +185,40 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
}
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
- GTEST_FLAG(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().c_str() + ".xml")).c_str();
- const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS
- EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
+ GTEST_FLAG(output) = "xml:path\\";
+ const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
+ EXPECT_TRUE(
+ _strcmpi(output_file.c_str(),
+ FilePath::ConcatPaths(
+ original_working_dir_,
+ FilePath("path\\gtest-options_test.xml")).c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ FilePath::ConcatPaths(
+ original_working_dir_,
+ FilePath("path\\gtest-options-ex_test.xml")).c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ FilePath::ConcatPaths(
+ original_working_dir_,
+ FilePath("path\\gtest_all_test.xml")).c_str()) == 0)
+ << " output_file = " << output_file;
#else
- EXPECT_EQ(expected_output_file, output_file.c_str());
+ GTEST_FLAG(output) = "xml:path/";
+ const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
+ // TODO(wan@google.com): libtool causes the test binary file to be
+ // named lt-gtest-options_test. Therefore the output file may be
+ // named .../lt-gtest-options_test.xml. We should remove this
+ // hard-coded logic when Chandler Carruth's libtool replacement is
+ // ready.
+ EXPECT_TRUE(output_file == FilePath::ConcatPaths(original_working_dir_,
+ FilePath("path/gtest-options_test.xml")).c_str() ||
+ output_file == FilePath::ConcatPaths(original_working_dir_,
+ FilePath("path/lt-gtest-options_test.xml")).c_str() ||
+ output_file == FilePath::ConcatPaths(original_working_dir_,
+ FilePath("path/gtest_all_test.xml")).c_str() ||
+ output_file == FilePath::ConcatPaths(original_working_dir_,
+ FilePath("path/lt-gtest_all_test.xml")).c_str())
+ << " output_file = " << output_file;
#endif
}
@@ -190,20 +236,29 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#if GTEST_OS_WINDOWS
- const std::string path = "c:\\tmp\\";
-#else
- const std::string path = "/tmp/";
-#endif
-
- GTEST_FLAG(output) = "xml:" + path;
- const std::string expected_output_file =
- path + GetCurrentExecutableName().c_str() + ".xml";
+ GTEST_FLAG(output) = "xml:c:\\tmp\\";
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
-
-#if GTEST_OS_WINDOWS
- EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
+ EXPECT_TRUE(
+ _strcmpi(output_file.c_str(),
+ FilePath("c:\\tmp\\gtest-options_test.xml").c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ FilePath("c:\\tmp\\gtest-options-ex_test.xml").c_str()) == 0 ||
+ _strcmpi(output_file.c_str(),
+ FilePath("c:\\tmp\\gtest_all_test.xml").c_str()) == 0)
+ << " output_file = " << output_file;
#else
- EXPECT_EQ(expected_output_file, output_file.c_str());
+ GTEST_FLAG(output) = "xml:/tmp/";
+ const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
+ // TODO(wan@google.com): libtool causes the test binary file to be
+ // named lt-gtest-options_test. Therefore the output file may be
+ // named .../lt-gtest-options_test.xml. We should remove this
+ // hard-coded logic when Chandler Carruth's libtool replacement is
+ // ready.
+ EXPECT_TRUE(output_file == "/tmp/gtest-options_test.xml" ||
+ output_file == "/tmp/lt-gtest-options_test.xml" ||
+ output_file == "/tmp/gtest_all_test.xml" ||
+ output_file == "/tmp/lt-gtest_all_test.xml")
+ << " output_file = " << output_file;
#endif
}