diff options
author | Riceball LEE <snowyu.lee@gmail.com> | 2021-11-01 20:27:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 12:27:46 +0000 |
commit | 693f98373bc4681d8eac1ab898f9ca9b9c9860d2 (patch) | |
tree | 638b1434b4a693c33cfc9f34eba23766503d5f78 /src/unittest/test_gettext.cpp | |
parent | 6910c8d920acedb3f1df1ac03a5cdf14f5fb6081 (diff) | |
download | minetest-693f98373bc4681d8eac1ab898f9ca9b9c9860d2.tar.gz minetest-693f98373bc4681d8eac1ab898f9ca9b9c9860d2.tar.bz2 minetest-693f98373bc4681d8eac1ab898f9ca9b9c9860d2.zip |
Localize error messages in mainmenu (#11495)
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: rubenwardy <rw@rubenwardy.com>
Diffstat (limited to 'src/unittest/test_gettext.cpp')
-rw-r--r-- | src/unittest/test_gettext.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/unittest/test_gettext.cpp b/src/unittest/test_gettext.cpp new file mode 100644 index 000000000..98f73ec62 --- /dev/null +++ b/src/unittest/test_gettext.cpp @@ -0,0 +1,47 @@ +#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 testSnfmtgettext(); + void testFmtgettext(); +}; + +static TestGettext g_test_instance; + +void TestGettext::runTests(IGameDef *gamedef) +{ + TEST(testFmtgettext); +} + +void TestGettext::testFmtgettext() +{ + std::string buf = fmtgettext("Viewing range changed to %d", 12); + UASSERTEQ(std::string, buf, "Viewing range changed to 12"); + buf = fmtgettext( + "You are about to join this server with the name \"%s\" for the " + "first time.\n" + "If you proceed, a new account using your credentials will be " + "created on this server.\n" + "Please retype your password and click 'Register and Join' to " + "confirm account creation, or click 'Cancel' to abort." + , "A"); + UASSERTEQ(std::string, buf, + "You are about to join this server with the name \"A\" for the " + "first time.\n" + "If you proceed, a new account using your credentials will be " + "created on this server.\n" + "Please retype your password and click 'Register and Join' to " + "confirm account creation, or click 'Cancel' to abort." + ); +} |