Skip to content

Commit c77521a

Browse files
committed
Implement unit tests for localization (Issue #58)
1 parent c96565a commit c77521a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

testsuite/testpappl.c

+61
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,20 @@ test_api(pappl_system_t *system) // I - System
11691169
size_t get_size, // Size for "get" call
11701170
set_size; // Size for ", set" call
11711171
pappl_printer_t *printer; // Current printer
1172+
pappl_loc_t *loc; // Current localization
11721173
_pappl_testprinter_t pdata; // Printer test data
1174+
const char *key = "A printer with that name already exists.",
1175+
// Key string
1176+
*text; // Localized text
1177+
static const char * const languages[] =
1178+
{
1179+
"de",
1180+
"en",
1181+
"es",
1182+
"fr",
1183+
"it",
1184+
"ja"
1185+
};
11731186
static const char * const set_locations[10][2] =
11741187
{
11751188
// Some wonders of the ancient world (all north-eastern portion of globe...)
@@ -1197,6 +1210,54 @@ test_api(pappl_system_t *system) // I - System
11971210
};
11981211

11991212

1213+
for (i = 0; i < (int)(sizeof(languages) / sizeof(languages[0])); i ++)
1214+
{
1215+
// papplSystemFindLoc
1216+
testBegin("api: papplSystemFindLoc('%s')", languages[i]);
1217+
if ((loc = papplSystemFindLoc(system, languages[i])) == NULL)
1218+
{
1219+
testEnd(false);
1220+
pass = false;
1221+
}
1222+
else
1223+
testEnd(true);
1224+
1225+
// papplLocGetString
1226+
testBegin("api: papplLocGetString('%s')", key);
1227+
if ((text = papplLocGetString(loc, key)) == NULL || text == key)
1228+
{
1229+
testEndMessage(false, "got %p", text);
1230+
pass = false;
1231+
}
1232+
else if (!strcmp(key, text) && strcmp(languages[i], "en"))
1233+
{
1234+
testEndMessage(false, "not localized");
1235+
pass = false;
1236+
}
1237+
else
1238+
testEndMessage(true, "got '%s'", text);
1239+
}
1240+
1241+
// papplSystemFindLoc
1242+
testBegin("api: papplSystemFindLoc('zz')");
1243+
if ((loc = papplSystemFindLoc(system, "zz")) != NULL)
1244+
{
1245+
testEndMessage(false, "got %p");
1246+
pass = false;
1247+
}
1248+
else
1249+
testEndMessage(true, "got NULL");
1250+
1251+
// papplLocGetString
1252+
testBegin("api: papplLocGetString('%s')", key);
1253+
if ((text = papplLocGetString(loc, key)) != key)
1254+
{
1255+
testEndMessage(false, "got %p", text);
1256+
pass = false;
1257+
}
1258+
else
1259+
testEndMessage(true, "got key string");
1260+
12001261
// papplSystemGet/SetAdminGroup
12011262
testBegin("api: papplSystemGetAdminGroup");
12021263
if (papplSystemGetAdminGroup(system, get_str, sizeof(get_str)))

0 commit comments

Comments
 (0)