Repository navigation
Expand file tree
/
Copy pathin_params.cpp
More file actions
61 lines (51 loc) · 1.88 KB
/
Copy pathin_params.cpp
File metadata and controls
61 lines (51 loc) · 1.88 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
#include "pch.h"
#include "winrt/test_component.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace test_component;
namespace
{
struct Value : implements<Value, IStringable>
{
Value(int32_t value) :
m_value(value)
{
}
hstring ToString()
{
return hstring{ std::to_wstring(m_value) };
}
private:
int32_t m_value{};
};
}
TEST_CASE("in_params")
{
Class object;
REQUIRE(object.InInt32(123) == L"123");
REQUIRE(object.InString(L"123") == L"123");
REQUIRE(object.InObject(make<Value>(123)) == L"123");
REQUIRE(object.InStringable(make<Value>(123)) == L"123");
REQUIRE(object.InStruct({ L"1", L"2" }) == L"12");
REQUIRE(object.InStructRef({ L"1", L"2" }) == L"12ref");
REQUIRE(object.InEnum(Signed::First) == L"First");
REQUIRE(object.InInt32Array({ 1,2 }) == L"12");
REQUIRE(object.InStringArray({ L"1", L"2" }) == L"12");
REQUIRE(object.InObjectArray({ make<Value>(1), make<Value>(2) }) == L"12");
REQUIRE(object.InStringableArray({ make<Value>(1), make<Value>(2) }) == L"12");
REQUIRE(object.InStructArray({ {L"1",L"2"}, {L"3",L"4"} }) == L"1234");
REQUIRE(object.InEnumArray({ Signed::First, Signed::Second }) == L"FirstSecond");
// Ensure 0-length arrays are passed as non-null pointers to the ABI,
// in order to keep RPC happy.
REQUIRE(object.InInt32Array({ }) == L"");
REQUIRE(object.InStringArray({ }) == L"");
REQUIRE(object.InObjectArray({ }) == L"");
REQUIRE(object.InStringableArray({ }) == L"");
REQUIRE(object.InStructArray({ }) == L"");
REQUIRE(object.InEnumArray({ }) == L"");
// params::hstring optimizations
REQUIRE(object.InString(L"") == L"");
REQUIRE(object.InString({}) == L"");
wchar_t non_const_string[1] = { L'\0' };
REQUIRE(object.InString(non_const_string) == L"");
}