1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Fix various code & correctness issues (#11815)

This commit is contained in:
sfan5 2021-12-05 14:40:30 +01:00 committed by GitHub
parent 7a043b3ebb
commit ff934d538c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 37 deletions

View file

@ -7,13 +7,12 @@ class TestGettext : public TestBase
public:
TestGettext() {
TestManager::registerTestModule(this);
}
}
const char *getName() { return "TestGettext"; }
void runTests(IGameDef *gamedef);
void testSnfmtgettext();
void testFmtgettext();
};
@ -24,24 +23,21 @@ 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 = 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."
);
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);
}