Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..."
This is compatible with compiling with "-Wundef" (#3267). PiperOrigin-RevId: 513943378 Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c
This commit is contained in:
committed by
Copybara-Service
parent
cead3d57c9
commit
23142843f7
@@ -39,7 +39,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@@ -49,7 +49,7 @@ namespace {
|
||||
// A test that's expected to fail.
|
||||
TEST(Foo, Bar) { EXPECT_EQ(2, 3); }
|
||||
|
||||
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_HAS_SEH && !defined(GTEST_OS_WINDOWS_MOBILE)
|
||||
// On Windows Mobile global exception handlers are not supported.
|
||||
LONG WINAPI
|
||||
ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) {
|
||||
@@ -60,12 +60,12 @@ ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) {
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
// Suppresses display of the Windows error dialog upon encountering
|
||||
// a general protection fault (segment violation).
|
||||
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
|
||||
|
||||
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_HAS_SEH && !defined(GTEST_OS_WINDOWS_MOBILE)
|
||||
|
||||
// The default unhandled exception filter does not always exit
|
||||
// with the exception code as exit code - for example it exits with
|
||||
|
||||
@@ -39,7 +39,7 @@ using testing::internal::AlwaysTrue;
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
#include <direct.h> // For chdir().
|
||||
#include <fcntl.h> // For O_BINARY
|
||||
#include <io.h>
|
||||
@@ -52,7 +52,7 @@ using testing::internal::AlwaysTrue;
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if GTEST_OS_LINUX
|
||||
#ifdef GTEST_OS_LINUX
|
||||
#include <sys/time.h>
|
||||
#endif // GTEST_OS_LINUX
|
||||
|
||||
@@ -200,7 +200,7 @@ int DieInDebugElse12(int* sideeffect) {
|
||||
return 12;
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
// Death in dbg due to Windows CRT assertion failure, not opt.
|
||||
int DieInCRTDebugElse12(int* sideeffect) {
|
||||
@@ -220,7 +220,7 @@ int DieInCRTDebugElse12(int* sideeffect) {
|
||||
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
|
||||
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA)
|
||||
|
||||
// Tests the ExitedWithCode predicate.
|
||||
TEST(ExitStatusPredicateTest, ExitedWithCode) {
|
||||
@@ -374,7 +374,7 @@ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
|
||||
ASSERT_DEATH(_exit(1), "");
|
||||
}
|
||||
|
||||
#if GTEST_OS_LINUX
|
||||
#ifdef GTEST_OS_LINUX
|
||||
void SigprofAction(int, siginfo_t*, void*) { /* no op */
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode
|
||||
// In debug mode, the calls to _CrtSetReportMode and _CrtSetReportFile enable
|
||||
@@ -693,7 +693,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
|
||||
*aborted = false;
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
|
||||
printf(
|
||||
"This test should be considered failing if it shows "
|
||||
@@ -805,14 +805,14 @@ static void TestExitMacros() {
|
||||
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
|
||||
ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), "");
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
// Of all signals effects on the process exit code, only those of SIGABRT
|
||||
// are documented on Windows.
|
||||
// See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c.
|
||||
EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar";
|
||||
|
||||
#elif !GTEST_OS_FUCHSIA
|
||||
#elif !defined(GTEST_OS_FUCHSIA)
|
||||
|
||||
// Fuchsia has no unix signals.
|
||||
EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo";
|
||||
@@ -1177,7 +1177,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
|
||||
EXPECT_STREQ("", GetLastErrnoDescription().c_str());
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
TEST(AutoHandleTest, AutoHandleWorks) {
|
||||
HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ASSERT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
@@ -1204,7 +1204,7 @@ TEST(AutoHandleTest, AutoHandleWorks) {
|
||||
}
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
typedef unsigned __int64 BiggestParsable;
|
||||
typedef signed __int64 BiggestSignedParsable;
|
||||
#else
|
||||
@@ -1301,7 +1301,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
|
||||
EXPECT_EQ(123, char_result);
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
TEST(EnvironmentTest, HandleFitsIntoSizeT) {
|
||||
ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#include "gtest/internal/gtest-filepath.h"
|
||||
#include "src/gtest-internal-inl.h"
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
#include <windows.h> // NOLINT
|
||||
#elif GTEST_OS_WINDOWS
|
||||
#elif defined(GTEST_OS_WINDOWS)
|
||||
#include <direct.h> // NOLINT
|
||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace testing {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
// Windows CE doesn't have the remove C function.
|
||||
int remove(const char* path) {
|
||||
@@ -80,7 +80,7 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
|
||||
const FilePath cwd = FilePath::GetCurrentDir();
|
||||
posix::ChDir(original_dir.c_str());
|
||||
|
||||
#if GTEST_OS_WINDOWS || GTEST_OS_OS2
|
||||
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_OS2)
|
||||
|
||||
// Skips the ":".
|
||||
const char* const cwd_without_drive = strchr(cwd.c_str(), ':');
|
||||
@@ -174,7 +174,7 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {
|
||||
|
||||
// RemoveFileName "" -> "./"
|
||||
TEST(RemoveFileNameTest, EmptyName) {
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
// On Windows CE, we use the root as the current directory.
|
||||
EXPECT_EQ(GTEST_PATH_SEP_, FilePath("").RemoveFileName().string());
|
||||
#else
|
||||
@@ -357,7 +357,7 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
|
||||
}
|
||||
|
||||
TEST(DirectoryTest, RootDirectoryExists) {
|
||||
#if GTEST_OS_WINDOWS // We are on Windows.
|
||||
#ifdef GTEST_OS_WINDOWS // We are on Windows.
|
||||
char current_drive[_MAX_PATH]; // NOLINT
|
||||
current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1);
|
||||
current_drive[1] = ':';
|
||||
@@ -369,7 +369,7 @@ TEST(DirectoryTest, RootDirectoryExists) {
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
|
||||
const int saved_drive_ = _getdrive();
|
||||
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
|
||||
@@ -387,7 +387,7 @@ TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
|
||||
}
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
||||
// Windows CE _does_ consider an empty directory to exist.
|
||||
TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
|
||||
EXPECT_FALSE(FilePath("").DirectoryExists());
|
||||
@@ -395,7 +395,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
TEST(DirectoryTest, CurrentDirectoryExists) {
|
||||
#if GTEST_OS_WINDOWS // We are on Windows.
|
||||
#ifdef GTEST_OS_WINDOWS // We are on Windows.
|
||||
#ifndef _WIN32_CE // Windows CE doesn't have a current directory.
|
||||
|
||||
EXPECT_TRUE(FilePath(".").DirectoryExists());
|
||||
@@ -423,7 +423,7 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) {
|
||||
// "/bar" == //bar" == "///bar"
|
||||
TEST(NormalizeTest, MultipleConsecutiveSeparatorsAtStringStart) {
|
||||
EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ "bar").string());
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
EXPECT_EQ(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar",
|
||||
FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string());
|
||||
#else
|
||||
@@ -620,7 +620,7 @@ TEST(FilePathTest, IsDirectory) {
|
||||
TEST(FilePathTest, IsAbsolutePath) {
|
||||
EXPECT_FALSE(FilePath("is" GTEST_PATH_SEP_ "relative").IsAbsolutePath());
|
||||
EXPECT_FALSE(FilePath("").IsAbsolutePath());
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
EXPECT_TRUE(
|
||||
FilePath("c:\\" GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative")
|
||||
.IsAbsolutePath());
|
||||
@@ -638,7 +638,7 @@ TEST(FilePathTest, IsAbsolutePath) {
|
||||
}
|
||||
|
||||
TEST(FilePathTest, IsRootDirectory) {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
EXPECT_TRUE(FilePath("a:\\").IsRootDirectory());
|
||||
EXPECT_TRUE(FilePath("Z:/").IsRootDirectory());
|
||||
EXPECT_TRUE(FilePath("e://").IsRootDirectory());
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
#include <windows.h>
|
||||
#elif GTEST_OS_WINDOWS
|
||||
#elif defined(GTEST_OS_WINDOWS)
|
||||
#include <direct.h>
|
||||
#elif GTEST_OS_OS2
|
||||
#elif defined(GTEST_OS_OS2)
|
||||
// For strcasecmp on OS/2
|
||||
#include <strings.h>
|
||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||
@@ -92,7 +92,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
|
||||
.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());
|
||||
@@ -101,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 =
|
||||
@@ -123,7 +123,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
|
||||
if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
|
||||
}
|
||||
|
||||
#if !GTEST_OS_FUCHSIA
|
||||
#ifndef GTEST_OS_FUCHSIA
|
||||
|
||||
class XmlOutputChangeDirTest : public Test {
|
||||
protected:
|
||||
@@ -176,7 +176,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
|
||||
.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());
|
||||
@@ -184,7 +184,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
|
||||
}
|
||||
|
||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
GTEST_FLAG_SET(output, "xml:c:\\tmp\\filename.abc");
|
||||
EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(),
|
||||
UnitTestOptions::GetAbsolutePathToOutputFile());
|
||||
@@ -196,7 +196,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
|
||||
}
|
||||
|
||||
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
const std::string path = "c:\\tmp\\";
|
||||
#else
|
||||
const std::string path = "/tmp/";
|
||||
@@ -208,7 +208,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
|
||||
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());
|
||||
|
||||
@@ -1028,7 +1028,7 @@ int main(int argc, char** argv) {
|
||||
if (GTEST_FLAG_GET(internal_run_death_test) != "") {
|
||||
// Skip the usual output capturing if we're running as the child
|
||||
// process of an threadsafe-style death test.
|
||||
#if GTEST_OS_WINDOWS
|
||||
#if defined(GTEST_OS_WINDOWS)
|
||||
posix::FReopen("nul:", "w", stdout);
|
||||
#else
|
||||
posix::FReopen("/dev/null", "w", stdout);
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
|
||||
#if GTEST_OS_MAC
|
||||
#ifdef GTEST_OS_MAC
|
||||
#include <time.h>
|
||||
#endif // GTEST_OS_MAC
|
||||
|
||||
@@ -281,9 +281,11 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
|
||||
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1));
|
||||
}
|
||||
|
||||
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \
|
||||
GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
|
||||
GTEST_OS_NETBSD || GTEST_OS_OPENBSD || GTEST_OS_GNU_HURD
|
||||
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || \
|
||||
defined(GTEST_OS_QNX) || defined(GTEST_OS_FUCHSIA) || \
|
||||
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
|
||||
defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \
|
||||
defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_GNU_HURD)
|
||||
void* ThreadFunc(void* data) {
|
||||
internal::Mutex* mutex = static_cast<internal::Mutex*>(data);
|
||||
mutex->Lock();
|
||||
@@ -916,7 +918,7 @@ TEST(RETest, PartialMatchWorks) {
|
||||
|
||||
#endif // GTEST_USES_POSIX_RE
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
TEST(CaptureTest, CapturesStdout) {
|
||||
CaptureStdout();
|
||||
@@ -1064,7 +1066,7 @@ class AtomicCounterWithMutex {
|
||||
|
||||
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex));
|
||||
GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex));
|
||||
#elif GTEST_OS_WINDOWS
|
||||
#elif defined(GTEST_OS_WINDOWS)
|
||||
// On Windows, performing an interlocked access puts up a memory barrier.
|
||||
volatile LONG dummy = 0;
|
||||
::InterlockedIncrement(&dummy);
|
||||
@@ -1146,14 +1148,14 @@ class DestructorCall {
|
||||
public:
|
||||
DestructorCall() {
|
||||
invoked_ = false;
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
wait_event_.Reset(::CreateEvent(NULL, TRUE, FALSE, NULL));
|
||||
GTEST_CHECK_(wait_event_.Get() != NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CheckDestroyed() const {
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
if (::WaitForSingleObject(wait_event_.Get(), 1000) != WAIT_OBJECT_0)
|
||||
return false;
|
||||
#endif
|
||||
@@ -1162,7 +1164,7 @@ class DestructorCall {
|
||||
|
||||
void ReportDestroyed() {
|
||||
invoked_ = true;
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
::SetEvent(wait_event_.Get());
|
||||
#endif
|
||||
}
|
||||
@@ -1178,7 +1180,7 @@ class DestructorCall {
|
||||
|
||||
private:
|
||||
bool invoked_;
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
AutoHandle wait_event_;
|
||||
#endif
|
||||
static std::vector<DestructorCall*>* const list_;
|
||||
@@ -1278,12 +1280,12 @@ TEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) {
|
||||
|
||||
#endif // GTEST_IS_THREADSAFE
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
TEST(WindowsTypesTest, HANDLEIsVoidStar) {
|
||||
StaticAssertTypeEq<HANDLE, void*>();
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
|
||||
#if defined(GTEST_OS_WINDOWS_MINGW) && !defined(__MINGW64_VERSION_MAJOR)
|
||||
TEST(WindowsTypesTest, _CRITICAL_SECTIONIs_CRITICAL_SECTION) {
|
||||
StaticAssertTypeEq<CRITICAL_SECTION, _CRITICAL_SECTION>();
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ TEST(PrintBuiltInTypeTest, Integer) {
|
||||
// Size types.
|
||||
TEST(PrintBuiltInTypeTest, Size_t) {
|
||||
EXPECT_EQ("1", Print(sizeof('a'))); // size_t.
|
||||
#if !GTEST_OS_WINDOWS
|
||||
#ifndef GTEST_OS_WINDOWS
|
||||
// Windows has no ssize_t type.
|
||||
EXPECT_EQ("-2", Print(static_cast<ssize_t>(-2))); // ssize_t.
|
||||
#endif // !GTEST_OS_WINDOWS
|
||||
|
||||
@@ -448,7 +448,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
|
||||
// tzset() distinguishes between the TZ variable being present and empty
|
||||
// and not being present, so we have to consider the case of time_zone
|
||||
// being NULL.
|
||||
#if defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW
|
||||
#if defined(_MSC_VER) || defined(GTEST_OS_WINDOWS_MINGW)
|
||||
// ...Unless it's MSVC, whose standard library's _putenv doesn't
|
||||
// distinguish between an empty and a missing variable.
|
||||
const std::string env_var =
|
||||
@@ -458,7 +458,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
|
||||
tzset();
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#else
|
||||
#if GTEST_OS_LINUX_ANDROID && __ANDROID_API__ < 21
|
||||
#if defined(GTEST_OS_LINUX_ANDROID) && __ANDROID_API__ < 21
|
||||
// Work around KitKat bug in tzset by setting "UTC" before setting "UTC+00".
|
||||
// See https://github.com/android/ndk/issues/1604.
|
||||
setenv("TZ", "UTC", 1);
|
||||
@@ -1090,7 +1090,7 @@ TEST(StringTest, CaseInsensitiveWideCStringEquals) {
|
||||
EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"FOOBAR", L"foobar"));
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
// Tests String::ShowWideCString().
|
||||
TEST(StringTest, ShowWideCString) {
|
||||
@@ -1099,7 +1099,7 @@ TEST(StringTest, ShowWideCString) {
|
||||
EXPECT_STREQ("foo", String::ShowWideCString(L"foo").c_str());
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
TEST(StringTest, AnsiAndUtf16Null) {
|
||||
EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));
|
||||
EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));
|
||||
@@ -1676,7 +1676,7 @@ TEST_F(GTestFlagSaverTest, VerifyGTestFlags) { VerifyAndModifyFlags(); }
|
||||
// value. If the value argument is "", unsets the environment
|
||||
// variable. The caller must ensure that both arguments are not NULL.
|
||||
static void SetEnv(const char* name, const char* value) {
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
#ifdef GTEST_OS_WINDOWS_MOBILE
|
||||
// Environment variables are not supported on Windows CE.
|
||||
return;
|
||||
#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
|
||||
@@ -1699,7 +1699,7 @@ static void SetEnv(const char* name, const char* value) {
|
||||
// We cast away the 'const' since that would work for both variants.
|
||||
putenv(const_cast<char*>(added_env[name]->c_str()));
|
||||
delete prev_env;
|
||||
#elif GTEST_OS_WINDOWS // If we are on Windows proper.
|
||||
#elif defined(GTEST_OS_WINDOWS) // If we are on Windows proper.
|
||||
_putenv((Message() << name << "=" << value).GetString().c_str());
|
||||
#else
|
||||
if (*value == '\0') {
|
||||
@@ -1710,7 +1710,7 @@ static void SetEnv(const char* name, const char* value) {
|
||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||
}
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
||||
// Environment variables are not supported on Windows CE.
|
||||
|
||||
using testing::internal::Int32FromGTestEnv;
|
||||
@@ -1819,7 +1819,7 @@ TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
|
||||
// Tests that Int32FromEnvOrDie() parses the value of the var or
|
||||
// returns the correct default.
|
||||
// Environment variables are not supported on Windows CE.
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
||||
TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {
|
||||
EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333));
|
||||
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "123");
|
||||
@@ -1892,7 +1892,7 @@ TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) {
|
||||
// Tests that sharding is enabled if total_shards > 1 and
|
||||
// we are not in a death test subprocess.
|
||||
// Environment variables are not supported on Windows CE.
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#ifndef GTEST_OS_WINDOWS_MOBILE
|
||||
TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) {
|
||||
SetEnv(index_var_, "4");
|
||||
SetEnv(total_var_, "22");
|
||||
@@ -3926,7 +3926,7 @@ TEST(AssertionTest, NamedEnum) {
|
||||
enum {
|
||||
kCaseA = -1,
|
||||
|
||||
#if GTEST_OS_LINUX
|
||||
#ifdef GTEST_OS_LINUX
|
||||
|
||||
// We want to test the case where the size of the anonymous enum is
|
||||
// larger than sizeof(int), to make sure our implementation of the
|
||||
@@ -3949,7 +3949,7 @@ enum {
|
||||
};
|
||||
|
||||
TEST(AssertionTest, AnonymousEnum) {
|
||||
#if GTEST_OS_LINUX
|
||||
#ifdef GTEST_OS_LINUX
|
||||
|
||||
EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB));
|
||||
|
||||
@@ -3983,7 +3983,7 @@ TEST(AssertionTest, AnonymousEnum) {
|
||||
|
||||
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
|
||||
static HRESULT UnexpectedHRESULTFailure() { return E_UNEXPECTED; }
|
||||
|
||||
@@ -4343,7 +4343,7 @@ TEST(AssertionWithMessageTest, ASSERT_TRUE) {
|
||||
"(null)(null)");
|
||||
}
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
// Tests using wide strings in assertion messages.
|
||||
TEST(AssertionWithMessageTest, WideStringMessage) {
|
||||
EXPECT_NONFATAL_FAILURE(
|
||||
@@ -6224,7 +6224,7 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if GTEST_OS_WINDOWS
|
||||
#ifdef GTEST_OS_WINDOWS
|
||||
// Tests parsing wide strings.
|
||||
TEST_F(ParseFlagsTest, WideStrings) {
|
||||
const wchar_t* argv[] = {L"foo.exe",
|
||||
@@ -6614,7 +6614,7 @@ TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {
|
||||
TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
|
||||
GTEST_FLAG_SET(color, "auto");
|
||||
|
||||
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
|
||||
#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW)
|
||||
// On Windows, we ignore the TERM variable as it's usually not set.
|
||||
|
||||
SetEnv("TERM", "dumb");
|
||||
|
||||
Reference in New Issue
Block a user