forked from microsoft/cppwinrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoundation.cpp
More file actions
68 lines (57 loc) · 1.5 KB
/
Copy pathfoundation.cpp
File metadata and controls
68 lines (57 loc) · 1.5 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
#include "pch.h"
import std;
import winrt.Windows.Foundation;
using namespace winrt;
using namespace Windows::Foundation;
TEST_CASE("module_uri")
{
Uri uri(L"https://example.com/path?query=1");
REQUIRE(!uri.AbsoluteUri().empty());
REQUIRE(uri.Host() == L"example.com");
REQUIRE(uri.Path() == L"/path");
}
TEST_CASE("module_property_value")
{
auto pv = PropertyValue::CreateInt32(42);
REQUIRE(pv.as<IPropertyValue>().GetInt32() == 42);
auto pvs = PropertyValue::CreateString(L"hello");
REQUIRE(pvs.as<IPropertyValue>().GetString() == L"hello");
}
TEST_CASE("module_hstring")
{
hstring text = L"C++/WinRT modules";
REQUIRE(!text.empty());
REQUIRE(text.size() == 17);
hstring empty;
REQUIRE(empty.empty());
REQUIRE(empty.size() == 0);
}
TEST_CASE("module_events")
{
winrt::event<winrt::Windows::Foundation::EventHandler<int>> my_event;
int received = 0;
auto token = my_event.add([&](auto&&, int value) { received = value; });
my_event(nullptr, 42);
REQUIRE(received == 42);
my_event.remove(token);
}
TEST_CASE("module_foundation_point")
{
Point p{ 5.0f, 10.0f };
REQUIRE(p.X == 5.0f);
REQUIRE(p.Y == 10.0f);
}
TEST_CASE("module_foundation_size")
{
Size s{ 800.0f, 600.0f };
REQUIRE(s.Width == 800.0f);
REQUIRE(s.Height == 600.0f);
}
TEST_CASE("module_foundation_rect")
{
Point origin{ 0.0f, 0.0f };
Size extent{ 100.0f, 200.0f };
Rect r(origin, extent);
REQUIRE(r.X == 0.0f);
REQUIRE(r.Width == 100.0f);
}