aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-01-22 19:09:11 +0100
committerGitHub <noreply@github.com>2020-01-22 19:09:11 +0100
commit1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec (patch)
treec49c16a69e9c555141960b4bca22a88df9b17a61 /src/unittest
parentfab3f5f7c8ce0cbfc27e509f065e3f4cfe28c514 (diff)
downloadminetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.tar.gz
minetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.tar.bz2
minetest-1892ff3c0db23ccdf7b0f6dc83cb1bdf4579b4ec.zip
StaticText/EnrichedString: Styling support (#9187)
* StaticText/EnrichedString: Styling support * Fix tooltip fg/bgcolor * Fix default color for substr(), add unittests
Diffstat (limited to 'src/unittest')
-rw-r--r--src/unittest/test_utilities.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp
index 8e8958d18..447b591e1 100644
--- a/src/unittest/test_utilities.cpp
+++ b/src/unittest/test_utilities.cpp
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "test.h"
#include <cmath>
+#include "util/enriched_string.h"
#include "util/numeric.h"
#include "util/string.h"
@@ -49,6 +50,7 @@ public:
void testUTF8();
void testRemoveEscapes();
void testWrapRows();
+ void testEnrichedString();
void testIsNumber();
void testIsPowerOfTwo();
void testMyround();
@@ -79,6 +81,7 @@ void TestUtilities::runTests(IGameDef *gamedef)
TEST(testUTF8);
TEST(testRemoveEscapes);
TEST(testWrapRows);
+ TEST(testEnrichedString);
TEST(testIsNumber);
TEST(testIsPowerOfTwo);
TEST(testMyround);
@@ -344,6 +347,23 @@ void TestUtilities::testWrapRows()
}
}
+void TestUtilities::testEnrichedString()
+{
+ EnrichedString str(L"Test bar");
+ irr::video::SColor color(0xFF, 0, 0, 0xFF);
+
+ UASSERT(str.substr(1, 3).getString() == L"est");
+ str += L" BUZZ";
+ UASSERT(str.substr(9, std::string::npos).getString() == L"BUZZ");
+ str.setDefaultColor(color); // Blue foreground
+ UASSERT(str.getColors()[5] == color);
+ // Green background, then white and yellow text
+ str = L"\x1b(b@#0F0)Regular \x1b(c@#FF0)yellow";
+ UASSERT(str.getColors()[2] == 0xFFFFFFFF);
+ str.setDefaultColor(color); // Blue foreground
+ UASSERT(str.getColors()[13] == 0xFFFFFF00); // Still yellow text
+ UASSERT(str.getBackground() == 0xFF00FF00); // Green background
+}
void TestUtilities::testIsNumber()
{