forked from microsoft/cppwinrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.cpp
More file actions
51 lines (44 loc) · 1.06 KB
/
format.cpp
File metadata and controls
51 lines (44 loc) · 1.06 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
#include "pch.h"
#ifdef __cpp_lib_format
#include <format>
struct stringable : winrt::implements<stringable, winrt::Windows::Foundation::IStringable>
{
winrt::hstring ToString()
{
return L"a stringable object";
}
};
TEST_CASE("format")
{
{
winrt::hstring str = L"World";
REQUIRE(std::format(L"Hello {}", str) == L"Hello World");
}
}
TEST_CASE("format_make")
{
{
winrt::Windows::Foundation::IStringable obj = winrt::make<stringable>();
REQUIRE(std::format(L"This is {}", obj) == L"This is a stringable object");
}
}
TEST_CASE("format_json")
{
{
winrt::Windows::Data::Json::JsonArray jsonArray;
REQUIRE(std::format(L"The contents of the array are: {}", jsonArray) == L"The contents of the array are: []");
}
}
TEST_CASE("format_wstring")
{
#if __cpp_lib_format >= 202207L
{
std::wstring str = L"World";
REQUIRE(winrt::format(L"Hello {}", str) == L"Hello World");
}
{
REQUIRE(winrt::format(L"C++/WinRT #{:d}", 1) == L"C++/WinRT #1");
}
#endif
}
#endif