aboutsummaryrefslogtreecommitdiff
path: root/src/unittest/test_gettext.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
commit21df26984da91143c15587f5a03c98d68c3adc4e (patch)
treeaaa707a628ad331f67890023dffe1b4f60dd01d3 /src/unittest/test_gettext.cpp
parentb09fc5de5cdb021f43ad32b7e3f50dc75c0bc622 (diff)
parenteabf05758e3ba5f6f4bb1b8d1d1f02179b84e410 (diff)
downloaddragonfireclient-21df26984da91143c15587f5a03c98d68c3adc4e.tar.xz
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/unittest/test_gettext.cpp')
-rw-r--r--src/unittest/test_gettext.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/unittest/test_gettext.cpp b/src/unittest/test_gettext.cpp
new file mode 100644
index 000000000..338a416d7
--- /dev/null
+++ b/src/unittest/test_gettext.cpp
@@ -0,0 +1,43 @@
+#include "test.h"
+#include "porting.h"
+#include "gettext.h"
+
+class TestGettext : public TestBase
+{
+public:
+ TestGettext() {
+ TestManager::registerTestModule(this);
+ }
+
+ const char *getName() { return "TestGettext"; }
+
+ void runTests(IGameDef *gamedef);
+
+ void testFmtgettext();
+};
+
+static TestGettext g_test_instance;
+
+void TestGettext::runTests(IGameDef *gamedef)
+{
+ TEST(testFmtgettext);
+}
+
+// Make sure updatepo.sh does not pick up the strings
+#define dummyname fmtgettext
+
+void TestGettext::testFmtgettext()
+{
+ std::string buf = dummyname("sample text %d", 12);
+ UASSERTEQ(std::string, buf, "sample text 12");
+
+ std::string src, expect;
+ src = "You are about to join this server with the name \"%s\".\n";
+ expect = "You are about to join this server with the name \"foo\".\n";
+ for (int i = 0; i < 20; i++) {
+ src.append("loooong text");
+ expect.append("loooong text");
+ }
+ buf = dummyname(src.c_str(), "foo");
+ UASSERTEQ(const std::string &, buf, expect);
+}