forked from microsoft/cppwinrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhstring_empty.cpp
More file actions
27 lines (22 loc) · 820 Bytes
/
hstring_empty.cpp
File metadata and controls
27 lines (22 loc) · 820 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
#include "pch.h"
using namespace std::literals;
TEST_CASE("hstring_empty")
{
winrt::hstring s;
REQUIRE(s.empty());
REQUIRE(s.size() == 0);
REQUIRE(s == L""sv);
REQUIRE(std::distance(s.begin(), s.end()) == 0);
// Using wcslen to both validate that the strings are empty *and* that they are not null.
REQUIRE(wcslen(s.c_str()) == 0);
REQUIRE(wcslen(s.data()) == 0);
std::wstring_view v = s;
REQUIRE(v.empty());
REQUIRE(v.size() == 0);
REQUIRE(v == L""sv);
REQUIRE(std::distance(v.begin(), v.end()) == 0);
// Using wcslen to both validate that the strings are empty *and* that they are not null.
// This is not guaranteed for wstring_view, but is assumed by some code that creates a
// wstring_view from an hstring.
REQUIRE(wcslen(v.data()) == 0);
}