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
35 lines (30 loc) · 879 Bytes
/
format.cpp
File metadata and controls
35 lines (30 loc) · 879 Bytes
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
#include "pch.h"
#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");
}
{
winrt::Windows::Foundation::IStringable obj = winrt::make<stringable>();
REQUIRE(std::format(L"This is {}", obj) == L"This is a stringable object");
}
{
winrt::Windows::Data::Json::JsonArray jsonArray;
REQUIRE(std::format(L"The contents of the array are: {}", jsonArray) == L"The contents of the array are: []");
}
#if __cpp_lib_format >= 202207L
{
std::wstring str = L"World";
REQUIRE(winrt::format(L"Hello {}", str) == L"Hello World");
}
#endif
}