Skip to content

Commit dcc74d4

Browse files
committed
Add some new testcases for when WINRT_REG_FREE is undefined
1 parent a346936 commit dcc74d4

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "pch.h"
2+
#include "winrt/test_component.h"
3+
4+
#ifdef WINRT_REG_FREE
5+
#error "This test needs WINRT_REG_FREE to be undefined"
6+
#endif
7+
8+
using namespace winrt;
9+
using namespace Windows::Foundation;
10+
using namespace test_component;
11+
12+
TEST_CASE("activation_withoug_regfree_system_type")
13+
{
14+
REQUIRE_NOTHROW(Uri(L"https://bing.com"));
15+
}
16+
17+
TEST_CASE("activation_withoug_regfree_fails")
18+
{
19+
bool threwException{ false };
20+
try
21+
{
22+
Class c;
23+
REQUIRE(false);
24+
}
25+
catch (winrt::hresult_class_not_registered& e)
26+
{
27+
threwException = true;
28+
REQUIRE(e.code() == winrt::impl::error_class_not_registered);
29+
}
30+
31+
REQUIRE(threwException);
32+
}

test/test_cpp20/test_cpp20.vcxproj

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@
123123
<OptimizeReferences>true</OptimizeReferences>
124124
</Link>
125125
<PreBuildEvent>
126-
<Command>
127-
</Command>
126+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
128127
</PreBuildEvent>
129128
<PostBuildEvent>
130129
<Command>
@@ -142,8 +141,7 @@
142141
<SubSystem>Console</SubSystem>
143142
</Link>
144143
<PreBuildEvent>
145-
<Command>
146-
</Command>
144+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
147145
</PreBuildEvent>
148146
<PostBuildEvent>
149147
<Command>
@@ -161,8 +159,7 @@
161159
<SubSystem>Console</SubSystem>
162160
</Link>
163161
<PreBuildEvent>
164-
<Command>
165-
</Command>
162+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
166163
</PreBuildEvent>
167164
<PostBuildEvent>
168165
<Command>
@@ -180,8 +177,7 @@
180177
<SubSystem>Console</SubSystem>
181178
</Link>
182179
<PreBuildEvent>
183-
<Command>
184-
</Command>
180+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
185181
</PreBuildEvent>
186182
<PostBuildEvent>
187183
<Command>
@@ -199,8 +195,7 @@
199195
<SubSystem>Console</SubSystem>
200196
</Link>
201197
<PreBuildEvent>
202-
<Command>
203-
</Command>
198+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
204199
</PreBuildEvent>
205200
<PostBuildEvent>
206201
<Command>
@@ -222,8 +217,7 @@
222217
<OptimizeReferences>true</OptimizeReferences>
223218
</Link>
224219
<PreBuildEvent>
225-
<Command>
226-
</Command>
220+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
227221
</PreBuildEvent>
228222
<PostBuildEvent>
229223
<Command>
@@ -245,8 +239,7 @@
245239
<OptimizeReferences>true</OptimizeReferences>
246240
</Link>
247241
<PreBuildEvent>
248-
<Command>
249-
</Command>
242+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
250243
</PreBuildEvent>
251244
<PostBuildEvent>
252245
<Command>
@@ -268,8 +261,7 @@
268261
<OptimizeReferences>true</OptimizeReferences>
269262
</Link>
270263
<PreBuildEvent>
271-
<Command>
272-
</Command>
264+
<Command>$(CppWinRTDir)cppwinrt -in $(OutputPath)test_component.winmd $(OutputPath)test_component_no_pch.winmd -out "$(ProjectDir)Generated Files" -ref sdk -verbose -fastabi</Command>
273265
</PreBuildEvent>
274266
<PostBuildEvent>
275267
<Command>
@@ -280,6 +272,7 @@
280272
<ClInclude Include="pch.h" />
281273
</ItemGroup>
282274
<ItemGroup>
275+
<ClCompile Include="activation_without_regfree.cpp" />
283276
<ClCompile Include="array_span.cpp" />
284277
<ClCompile Include="await_completed.cpp" />
285278
<ClCompile Include="custom_error.cpp" />

0 commit comments

Comments
 (0)