diff options
author | sfan5 <sfan5@live.de> | 2021-01-29 13:09:17 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-02-02 20:46:08 +0100 |
commit | 5e392cf34f8e062dd0533619921223656e32598a (patch) | |
tree | f7cbd5f6d5290545adb4ce0beb07a94352043818 /src/unittest | |
parent | 7ebd5da9cd4a227dcdc140a495f264a97277b3a3 (diff) | |
download | minetest-5e392cf34f8e062dd0533619921223656e32598a.tar.gz minetest-5e392cf34f8e062dd0533619921223656e32598a.tar.bz2 minetest-5e392cf34f8e062dd0533619921223656e32598a.zip |
Refactor utf8_to_wide/wide_to_utf8 functions
Diffstat (limited to 'src/unittest')
-rw-r--r-- | src/unittest/test_utilities.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp index 447b591e1..5559cdbf2 100644 --- a/src/unittest/test_utilities.cpp +++ b/src/unittest/test_utilities.cpp @@ -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() |