1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Refactor utf8_to_wide/wide_to_utf8 functions

This commit is contained in:
sfan5 2021-01-29 13:09:17 +01:00
parent 7ebd5da9cd
commit 5e392cf34f
3 changed files with 40 additions and 38 deletions

View file

@ -302,9 +302,18 @@ void TestUtilities::testAsciiPrintableHelper()
void TestUtilities::testUTF8()
{
UASSERT(wide_to_utf8(utf8_to_wide("")) == "");
UASSERT(wide_to_utf8(utf8_to_wide("the shovel dug a crumbly node!"))
== "the shovel dug a crumbly node!");
UASSERT(utf8_to_wide("¤") == L"¤");
UASSERT(wide_to_utf8(L"¤") == "¤");
UASSERTEQ(std::string, wide_to_utf8(utf8_to_wide("")), "");
UASSERTEQ(std::string, wide_to_utf8(utf8_to_wide("the shovel dug a crumbly node!")),
"the shovel dug a crumbly node!");
UASSERTEQ(std::string, wide_to_utf8(utf8_to_wide("-ä-")),
"-ä-");
UASSERTEQ(std::string, wide_to_utf8(utf8_to_wide("-\xF0\xA0\x80\x8B-")),
"-\xF0\xA0\x80\x8B-");
}
void TestUtilities::testRemoveEscapes()