File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -257,12 +257,19 @@ WINRT_EXPORT namespace winrt
257257
258258 const_pointer data () const noexcept
259259 {
260- return begin ();
260+ return c_str ();
261261 }
262262
263263 const_pointer c_str () const noexcept
264264 {
265- return begin ();
265+ if (!empty ())
266+ {
267+ return begin ();
268+ }
269+ else
270+ {
271+ return L" " ;
272+ }
266273 }
267274
268275 const_iterator begin () const noexcept
Original file line number Diff line number Diff line change 1+ #include " pch.h"
2+
3+ using namespace std ::literals;
4+
5+ TEST_CASE (" hstring_empty" )
6+ {
7+ winrt::hstring s;
8+ REQUIRE (s.empty ());
9+ REQUIRE (s.size () == 0 );
10+ REQUIRE (s == L" " sv);
11+ REQUIRE (std::distance (s.begin (), s.end ()) == 0 );
12+
13+ // Using wcslen to both validate that the strings are empty *and* that they are not null.
14+ REQUIRE (wcslen (s.c_str ()) == 0 );
15+ REQUIRE (wcslen (s.data ()) == 0 );
16+ }
Original file line number Diff line number Diff line change 363363 </ClCompile >
364364 <ClCompile Include =" GetMany.cpp" />
365365 <ClCompile Include =" get_activation_factory.cpp" />
366+ <ClCompile Include =" hstring_empty.cpp" />
366367 <ClCompile Include =" iid_ppv_args.cpp" />
367368 <ClCompile Include =" inspectable_interop.cpp" >
368369 <PrecompiledHeader Condition =" '$(Configuration)|$(Platform)'=='Debug|Win32'" >NotUsing</PrecompiledHeader >
You can’t perform that action at this time.
0 commit comments