]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testlang.c
4 * Localization test program for CUPS.
6 * Copyright 2007-2010 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Load the specified language and show the strings for yes and no.
23 * Include necessary headers...
26 #include "cups-private.h"
30 * 'main()' - Load the specified language and show the strings for yes and no.
33 int /* O - Exit status */
34 main(int argc
, /* I - Number of command-line arguments */
35 char *argv
[]) /* I - Command-line arguments */
37 int i
; /* Looping var */
38 int errors
= 0; /* Number of errors */
39 cups_lang_t
*language
; /* Message catalog */
40 cups_lang_t
*language2
; /* Message catalog */
41 struct lconv
*loc
; /* Locale data */
42 char buffer
[1024]; /* String buffer */
43 double number
; /* Number */
44 static const char * const tests
[] = /* Test strings */
57 language
= cupsLangDefault();
58 language2
= cupsLangDefault();
62 language
= cupsLangGet(argv
[1]);
63 language2
= cupsLangGet(argv
[1]);
66 if (language
!= language2
)
70 puts("**** ERROR: Language cache did not work! ****");
71 puts("First result from cupsLangGet:");
74 printf("Language = \"%s\"\n", language
->language
);
75 printf("Encoding = \"%s\"\n", _cupsEncodingName(language
->encoding
));
76 printf("No = \"%s\"\n", _cupsLangString(language
, "No"));
77 printf("Yes = \"%s\"\n", _cupsLangString(language
, "Yes"));
79 if (language
!= language2
)
81 puts("Second result from cupsLangGet:");
83 printf("Language = \"%s\"\n", language2
->language
);
84 printf("Encoding = \"%s\"\n", _cupsEncodingName(language2
->encoding
));
85 printf("No = \"%s\"\n", _cupsLangString(language2
, "No"));
86 printf("Yes = \"%s\"\n", _cupsLangString(language2
, "Yes"));
91 for (i
= 0; i
< (int)(sizeof(tests
) / sizeof(tests
[0])); i
++)
93 number
= _cupsStrScand(tests
[i
], NULL
, loc
);
95 printf("_cupsStrScand(\"%s\") number=%f\n", tests
[i
], number
);
97 _cupsStrFormatd(buffer
, buffer
+ sizeof(buffer
), number
, loc
);
99 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number
, buffer
);
101 if (strcmp(buffer
, tests
[i
]))
104 puts("**** ERROR: Bad formatted number! ****");