forked from microsoft/cppwinrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (56 loc) · 1.71 KB
/
main.cpp
File metadata and controls
70 lines (56 loc) · 1.71 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <crtdbg.h>
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
// Defining WINRT_CUSTOM_MODULE_LOCK means you need to provide your own winrt::get_module_lock implementation.
// This can be useful if you have some custom hosting environment that does not use DllCanUnloadNow.
#define WINRT_CUSTOM_MODULE_LOCK
namespace winrt
{
inline auto get_module_lock() noexcept
{
struct lock
{
uint32_t operator++() noexcept
{
return 123;
}
uint32_t operator--() noexcept
{
return 321;
}
operator uint32_t() const noexcept
{
return 101;
}
};
return lock{};
}
}
#include "winrt/Windows.Foundation.h"
namespace
{
struct CustomStringable : winrt::implements<CustomStringable, winrt::Windows::Foundation::IStringable>
{
winrt::hstring ToString()
{
return L"CustomStringable";
}
};
}
TEST_CASE("module_lock_custom")
{
REQUIRE(++winrt::get_module_lock() == 123);
REQUIRE(--winrt::get_module_lock() == 321);
REQUIRE(winrt::get_module_lock() == 101);
// Just validates that you can still construct an implementation with a custom module lock.
winrt::make<CustomStringable>();
}
int main(int const argc, char** argv)
{
std::set_terminate([] { reportFatal("Abnormal termination"); ExitProcess(1); });
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
(void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
return Catch::Session().run(argc, argv);
}