File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ namespace cage
7676 {
7777 const auto t = una::utf8to32u (view (inBuffer));
7878 CAGE_ASSERT (outBuffer.size () >= t.size ());
79- detail::memcpy (outBuffer.data (), t.data (), t.size () * sizeof (uint32));
79+ if (t.size ())
80+ detail::memcpy (outBuffer.data (), t.data (), t.size () * sizeof (uint32));
8081 outBuffer = PointerRange<uint32>(outBuffer.begin (), outBuffer.begin () + t.size ());
8182 }
8283
@@ -100,7 +101,8 @@ namespace cage
100101 {
101102 const auto t = una::utf32to8u (view (inBuffer));
102103 CAGE_ASSERT (outBuffer.size () >= t.size ());
103- detail::memcpy (outBuffer.data (), t.data (), t.size () * sizeof (char ));
104+ if (t.size ())
105+ detail::memcpy (outBuffer.data (), t.data (), t.size () * sizeof (char ));
104106 outBuffer = PointerRange<char >(outBuffer.begin (), outBuffer.begin () + t.size ());
105107 }
106108
Original file line number Diff line number Diff line change 1+ #include < vector>
2+
13#include " main.h"
24
35#include < cage-core/unicode.h>
@@ -13,6 +15,25 @@ namespace
1315 CAGE_TEST (a == c);
1416 CAGE_TEST (utf32Length (a) == b->size ());
1517 CAGE_TEST (utf8Length (b) == c.size ());
18+ CAGE_TEST (utfValid (" " ));
19+ CAGE_TEST (utf8to32 (" " ).empty ());
20+
21+ {
22+ std::vector<uint32> vec;
23+ vec.resize (utf32Length (a) + 5 );
24+ PointerRange<uint32> range = vec;
25+ utf8to32 (range, a);
26+ CAGE_TEST (range.size () == utf32Length (a));
27+ const String d = utf32to8string (range);
28+ CAGE_TEST (a == d);
29+ }
30+
31+ {
32+ std::vector<uint32> vec;
33+ PointerRange<uint32> range = vec;
34+ utf8to32 (range, " " );
35+ CAGE_TEST (range.empty ());
36+ }
1637 }
1738
1839 void testValidation ()
You can’t perform that action at this time.
0 commit comments