MCPcopy Create free account
hub / github.com/OpenPrinting/cups / test_language

Function test_language

cups/testlang.c:207–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 */
206
207static int /* O - Number of errors */
208test_language(const char *lang) /* I - Locale language code, NULL for default */
209{
210 int i; /* Looping var */
211 int errors = 0; /* Number of errors */
212 cups_lang_t *language = NULL, /* Message catalog */
213 *language2 = NULL; /* Message catalog (second time) */
214 struct lconv *loc; /* Locale data */
215 char buffer[1024]; /* String buffer */
216 double number; /* Number */
217 static const char * const tests[] = /* Test strings */
218 {
219 "1",
220 "-1",
221 "3",
222 "5.125"
223 };
224
225
226 // Override the locale environment as needed...
227 if (lang)
228 {
229 // Test the specified locale code...
230 setenv("LANG", lang, 1);
231 setenv("SOFTWARE", "CUPS/" CUPS_SVERSION, 1);
232
233 printf("cupsLangGet(\"%s\"): ", lang);
234 if ((language = cupsLangGet(lang)) == NULL)
235 {
236 puts("FAIL");
237 errors ++;
238 }
239 else if (strcasecmp(language->language, lang))
240 {
241 printf("FAIL (got \"%s\")\n", language->language);
242 errors ++;
243 }
244 else
245 puts("PASS");
246
247 printf("cupsLangGet(\"%s\") again: ", lang);
248 if ((language2 = cupsLangGet(lang)) == NULL)
249 {
250 puts("FAIL");
251 errors ++;
252 }
253 else if (strcasecmp(language2->language, lang))
254 {
255 printf("FAIL (got \"%s\")\n", language2->language);
256 errors ++;
257 }
258 else if (language2 != language)
259 {
260 puts("FAIL (cache failure)");
261 errors ++;
262 }
263 else
264 puts("PASS");

Callers 1

mainFunction · 0.85

Calls 6

cupsLangGetFunction · 0.85
cupsLangDefaultFunction · 0.85
_cupsEncodingNameFunction · 0.85
test_stringFunction · 0.85
_cupsStrScandFunction · 0.85
_cupsStrFormatdFunction · 0.85

Tested by

no test coverage detected