-
Notifications
You must be signed in to change notification settings - Fork 55
/
Main.cpp
50 lines (40 loc) · 1.32 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#include "common/Common.hpp"
#if defined(_DEBUG) && defined(_WIN32) && !defined(_INC_WINDOWS)
extern "C" unsigned long __stdcall IsDebuggerPresent();
#endif
class TestStatusLogger : public testing::EmptyTestEventListener {
public:
virtual void OnTestStart(testing::TestInfo const& test) override
{
std::ignore = test;
LOG_INFO("--- %s.%s", test.test_case_name(), test.name());
}
virtual void OnTestEnd(testing::TestInfo const& test) override
{
std::ignore = test;
LOG_INFO("=== %s.%s [%s]", test.test_case_name(), test.name(), test.result()->Passed() ? "OK" : "FAILED");
}
};
#ifdef _MSC_VER
#pragma warning(suppress:4447) // 'main' signature found without threading model. Consider using 'int main(Platform::Array<Platform::String^>^ args)'.
#define MAIN_CDECL __cdecl
#else
#define MAIN_CDECL
#endif
int MAIN_CDECL main(int argc, char** argv)
{
::testing::InitGoogleMock(&argc, argv);
::testing::UnitTest::GetInstance()->listeners().Append(new TestStatusLogger());
int result = RUN_ALL_TESTS();
#if defined(_DEBUG) && defined(_WIN32)
if (IsDebuggerPresent()) {
printf("Press Enter to close...");
getchar();
}
#endif
return result;
}