diff options
author | figec <raptor.ext@gmail.com> | 2015-06-18 21:34:17 +0300 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-18 23:39:23 +0200 |
commit | 3b65a6a36c3e910359c69cd3e3e3fd89e50ba23e (patch) | |
tree | bda855f40761027cff71191505df2131a0c8f63f /src/unittest | |
parent | e45ecad3ab401e169d1c8c9ba9448360b215b3e5 (diff) | |
download | minetest-3b65a6a36c3e910359c69cd3e3e3fd89e50ba23e.tar.gz minetest-3b65a6a36c3e910359c69cd3e3e3fd89e50ba23e.tar.bz2 minetest-3b65a6a36c3e910359c69cd3e3e3fd89e50ba23e.zip |
Fix wrap_rows at inner byte of multibyte sequence
Also fix UTF-8 inner byte bounds and make unittest for case this fixes.
Diffstat (limited to 'src/unittest')
-rw-r--r-- | src/unittest/test_utilities.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp index 9678a81eb..df90d37bd 100644 --- a/src/unittest/test_utilities.cpp +++ b/src/unittest/test_utilities.cpp @@ -243,13 +243,23 @@ void TestUtilities::testWrapRows() { UASSERT(wrap_rows("12345678",4) == "1234\n5678"); // test that wrap_rows doesn't wrap inside multibyte sequences - const unsigned char s[] = { - 0x2f, 0x68, 0x6f, 0x6d, 0x65, 0x2f, 0x72, 0x61, 0x70, 0x74, 0x6f, - 0x72, 0x2f, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0x2f, - 0x6d, 0x69, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x62, 0x69, - 0x6e, 0x2f, 0x2e, 0x2e, 0}; - std::string str((char *)s); - UASSERT(utf8_to_wide(wrap_rows(str, 20)) != L"<invalid UTF-8 string>"); + { + const unsigned char s[] = { + 0x2f, 0x68, 0x6f, 0x6d, 0x65, 0x2f, 0x72, 0x61, 0x70, 0x74, 0x6f, + 0x72, 0x2f, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0x2f, + 0x6d, 0x69, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x62, 0x69, + 0x6e, 0x2f, 0x2e, 0x2e, 0}; + std::string str((char *)s); + UASSERT(utf8_to_wide(wrap_rows(str, 20)) != L"<invalid UTF-8 string>"); + }; + { + const unsigned char s[] = { + 0x74, 0x65, 0x73, 0x74, 0x20, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, + 0xd1, 0x82, 0x20, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, + 0x20, 0xd1, 0x82, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0}; + std::string str((char *)s); + UASSERT(utf8_to_wide(wrap_rows(str, 8)) != L"<invalid UTF-8 string>"); + } } |