summaryrefslogtreecommitdiff
path: root/src/unittest/test_gettext.cpp
blob: 98f73ec627f559ea44176cf3fd98967d2ab1ae07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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."
  );
}