summaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorEkdohibs <nathanael.courant@laposte.net>2016-04-04 18:31:00 +0200
committerCraig Robbins <kde.psych@gmail.com>2016-04-24 03:54:11 +1000
commit48939df9a5ef1ff20f4f9717d1341b51a50dff14 (patch)
tree7325a70d4dbe445d4e3726f0aea402f3181906b4 /src/unittest
parent21079cc8ebae0bf694c1903c07bf3e1517feab99 (diff)
downloadminetest-48939df9a5ef1ff20f4f9717d1341b51a50dff14.tar.gz
minetest-48939df9a5ef1ff20f4f9717d1341b51a50dff14.tar.bz2
minetest-48939df9a5ef1ff20f4f9717d1341b51a50dff14.zip
Escape more strings: formspecs, item descriptions, infotexts...
Also, change the escape character to the more standard \x1b Thus, it can be used in the future for translation or colored text, for example.
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_utilities.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp
index 1785997de..d73975b9f 100644
--- a/src/unittest/test_utilities.cpp
+++ b/src/unittest/test_utilities.cpp
@@ -45,6 +45,7 @@ public:
void testStringAllowed();
void testAsciiPrintableHelper();
void testUTF8();
+ void testRemoveEscapes();
void testWrapRows();
void testIsNumber();
void testIsPowerOfTwo();
@@ -71,6 +72,7 @@ void TestUtilities::runTests(IGameDef *gamedef)
TEST(testStringAllowed);
TEST(testAsciiPrintableHelper);
TEST(testUTF8);
+ TEST(testRemoveEscapes);
TEST(testWrapRows);
TEST(testIsNumber);
TEST(testIsPowerOfTwo);
@@ -253,6 +255,23 @@ void TestUtilities::testUTF8()
== "the shovel dug a crumbly node!");
}
+void TestUtilities::testRemoveEscapes()
+{
+ UASSERT(unescape_enriched<wchar_t>(
+ L"abc\x1bXdef") == L"abcdef");
+ UASSERT(unescape_enriched<wchar_t>(
+ L"abc\x1b(escaped)def") == L"abcdef");
+ UASSERT(unescape_enriched<wchar_t>(
+ L"abc\x1b((escaped with parenthesis\\))def") == L"abcdef");
+ UASSERT(unescape_enriched<wchar_t>(
+ L"abc\x1b(incomplete") == L"abc");
+ UASSERT(unescape_enriched<wchar_t>(
+ L"escape at the end\x1b") == L"escape at the end");
+ // Nested escapes not supported
+ UASSERT(unescape_enriched<wchar_t>(
+ L"abc\x1b(outer \x1b(inner escape)escape)def") == L"abcescape)def");
+}
+
void TestUtilities::testWrapRows()
{
UASSERT(wrap_rows("12345678",4) == "1234\n5678");