"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googletest/test/googletest-options-test.cc" between
googletest-release-1.11.0.tar.gz and googletest-release-1.12.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

googletest-options-test.cc  (googletest-release-1.11.0):googletest-options-test.cc  (googletest-release-1.12.0)
skipping to change at line 42 skipping to change at line 42
// This file tests classes and functions used internally by // This file tests classes and functions used internally by
// Google Test. They are subject to change without notice. // Google Test. They are subject to change without notice.
// //
// This file is #included from gtest.cc, to avoid changing build or // This file is #included from gtest.cc, to avoid changing build or
// make-files on Windows and other platforms. Do not #include this file // make-files on Windows and other platforms. Do not #include this file
// anywhere else! // anywhere else!
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> #include <windows.h>
#elif GTEST_OS_WINDOWS #elif GTEST_OS_WINDOWS
# include <direct.h> #include <direct.h>
#elif GTEST_OS_OS2 #elif GTEST_OS_OS2
// For strcasecmp on OS/2 // For strcasecmp on OS/2
#include <strings.h> #include <strings.h>
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
namespace testing { namespace testing {
namespace internal { namespace internal {
namespace { namespace {
// Turns the given relative path into an absolute path. // Turns the given relative path into an absolute path.
FilePath GetAbsolutePathOf(const FilePath& relative_path) { FilePath GetAbsolutePathOf(const FilePath& relative_path) {
return FilePath::ConcatPaths(FilePath::GetCurrentDir(), relative_path); return FilePath::ConcatPaths(FilePath::GetCurrentDir(), relative_path);
} }
// Testing UnitTestOptions::GetOutputFormat/GetOutputFile. // Testing UnitTestOptions::GetOutputFormat/GetOutputFile.
TEST(XmlOutputTest, GetOutputFormatDefault) { TEST(XmlOutputTest, GetOutputFormatDefault) {
GTEST_FLAG(output) = ""; GTEST_FLAG_SET(output, "");
EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str()); EXPECT_STREQ("", UnitTestOptions::GetOutputFormat().c_str());
} }
TEST(XmlOutputTest, GetOutputFormat) { TEST(XmlOutputTest, GetOutputFormat) {
GTEST_FLAG(output) = "xml:filename"; GTEST_FLAG_SET(output, "xml:filename");
EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str()); EXPECT_STREQ("xml", UnitTestOptions::GetOutputFormat().c_str());
} }
TEST(XmlOutputTest, GetOutputFileDefault) { TEST(XmlOutputTest, GetOutputFileDefault) {
GTEST_FLAG(output) = ""; GTEST_FLAG_SET(output, "");
EXPECT_EQ(GetAbsolutePathOf(FilePath("test_detail.xml")).string(), EXPECT_EQ(GetAbsolutePathOf(FilePath("test_detail.xml")).string(),
UnitTestOptions::GetAbsolutePathToOutputFile()); UnitTestOptions::GetAbsolutePathToOutputFile());
} }
TEST(XmlOutputTest, GetOutputFileSingleFile) { TEST(XmlOutputTest, GetOutputFileSingleFile) {
GTEST_FLAG(output) = "xml:filename.abc"; GTEST_FLAG_SET(output, "xml:filename.abc");
EXPECT_EQ(GetAbsolutePathOf(FilePath("filename.abc")).string(), EXPECT_EQ(GetAbsolutePathOf(FilePath("filename.abc")).string(),
UnitTestOptions::GetAbsolutePathToOutputFile()); UnitTestOptions::GetAbsolutePathToOutputFile());
} }
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) { 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 = const std::string expected_output_file =
GetAbsolutePathOf( GetAbsolutePathOf(FilePath(std::string("path") + GTEST_PATH_SEP_ +
FilePath(std::string("path") + GTEST_PATH_SEP_ + GetCurrentExecutableName().string() + ".xml"))
GetCurrentExecutableName().string() + ".xml")).string(); .string();
const std::string& output_file = const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile(); UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else #else
EXPECT_EQ(expected_output_file, output_file.c_str()); EXPECT_EQ(expected_output_file, output_file.c_str());
#endif #endif
} }
TEST(OutputFileHelpersTest, GetCurrentExecutableName) { TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
skipping to change at line 118 skipping to change at line 118
#elif GTEST_OS_OS2 #elif GTEST_OS_OS2
const bool success = const bool success =
strcasecmp("googletest-options-test", exe_str.c_str()) == 0 || strcasecmp("googletest-options-test", exe_str.c_str()) == 0 ||
strcasecmp("gtest-options-ex_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_all_test", exe_str.c_str()) == 0 ||
strcasecmp("gtest_dll_test", exe_str.c_str()) == 0; strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
#elif GTEST_OS_FUCHSIA #elif GTEST_OS_FUCHSIA
const bool success = exe_str == "app"; const bool success = exe_str == "app";
#else #else
const bool success = const bool success =
exe_str == "googletest-options-test" || exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
exe_str == "gtest_all_test" || exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
exe_str == "lt-gtest_all_test" ||
exe_str == "gtest_dll_test";
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
if (!success) if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
FAIL() << "GetCurrentExecutableName() returns " << exe_str;
} }
#if !GTEST_OS_FUCHSIA #if !GTEST_OS_FUCHSIA
class XmlOutputChangeDirTest : public Test { class XmlOutputChangeDirTest : public Test {
protected: protected:
void SetUp() override { void SetUp() override {
original_working_dir_ = FilePath::GetCurrentDir(); original_working_dir_ = FilePath::GetCurrentDir();
posix::ChDir(".."); posix::ChDir("..");
// This will make the test fail if run from the root directory. // This will make the test fail if run from the root directory.
skipping to change at line 147 skipping to change at line 144
} }
void TearDown() override { void TearDown() override {
posix::ChDir(original_working_dir_.string().c_str()); posix::ChDir(original_working_dir_.string().c_str());
} }
FilePath original_working_dir_; FilePath original_working_dir_;
}; };
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {
GTEST_FLAG(output) = ""; GTEST_FLAG_SET(output, "");
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_, EXPECT_EQ(
FilePath("test_detail.xml")).string(), FilePath::ConcatPaths(original_working_dir_, FilePath("test_detail.xml"))
UnitTestOptions::GetAbsolutePathToOutputFile()); .string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {
GTEST_FLAG(output) = "xml"; GTEST_FLAG_SET(output, "xml");
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_, EXPECT_EQ(
FilePath("test_detail.xml")).string(), FilePath::ConcatPaths(original_working_dir_, FilePath("test_detail.xml"))
UnitTestOptions::GetAbsolutePathToOutputFile()); .string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
GTEST_FLAG(output) = "xml:filename.abc"; GTEST_FLAG_SET(output, "xml:filename.abc");
EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_, EXPECT_EQ(
FilePath("filename.abc")).string(), FilePath::ConcatPaths(original_working_dir_, FilePath("filename.abc"))
UnitTestOptions::GetAbsolutePathToOutputFile()); .string(),
UnitTestOptions::GetAbsolutePathToOutputFile());
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) { 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 = const std::string expected_output_file =
FilePath::ConcatPaths( FilePath::ConcatPaths(
original_working_dir_, original_working_dir_,
FilePath(std::string("path") + GTEST_PATH_SEP_ + FilePath(std::string("path") + GTEST_PATH_SEP_ +
GetCurrentExecutableName().string() + ".xml")).string(); GetCurrentExecutableName().string() + ".xml"))
.string();
const std::string& output_file = const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile(); UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else #else
EXPECT_EQ(expected_output_file, output_file.c_str()); EXPECT_EQ(expected_output_file, output_file.c_str());
#endif #endif
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc"; GTEST_FLAG_SET(output, "xml:c:\\tmp\\filename.abc");
EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(), EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(),
UnitTestOptions::GetAbsolutePathToOutputFile()); UnitTestOptions::GetAbsolutePathToOutputFile());
#else #else
GTEST_FLAG(output) ="xml:/tmp/filename.abc"; GTEST_FLAG_SET(output, "xml:/tmp/filename.abc");
EXPECT_EQ(FilePath("/tmp/filename.abc").string(), EXPECT_EQ(FilePath("/tmp/filename.abc").string(),
UnitTestOptions::GetAbsolutePathToOutputFile()); UnitTestOptions::GetAbsolutePathToOutputFile());
#endif #endif
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
const std::string path = "c:\\tmp\\"; const std::string path = "c:\\tmp\\";
#else #else
const std::string path = "/tmp/"; const std::string path = "/tmp/";
#endif #endif
GTEST_FLAG(output) = "xml:" + path; GTEST_FLAG_SET(output, "xml:" + path);
const std::string expected_output_file = const std::string expected_output_file =
path + GetCurrentExecutableName().string() + ".xml"; path + GetCurrentExecutableName().string() + ".xml";
const std::string& output_file = const std::string& output_file =
UnitTestOptions::GetAbsolutePathToOutputFile(); UnitTestOptions::GetAbsolutePathToOutputFile();
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());
#else #else
EXPECT_EQ(expected_output_file, output_file.c_str()); EXPECT_EQ(expected_output_file, output_file.c_str());
#endif #endif
 End of changes. 18 change blocks. 
33 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)