]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
bc44d920 | 2 | * "$Id: testlang.c 6649 2007-07-11 21:46:42Z mike $" |
ef416fc2 | 3 | * |
4 | * Localization test program for the Common UNIX Printing System (CUPS). | |
5 | * | |
bc44d920 | 6 | * Copyright 2007 by Apple Inc. |
ef416fc2 | 7 | * Copyright 1997-2006 by Easy Software Products. |
8 | * | |
9 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 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/". | |
ef416fc2 | 14 | * |
15 | * This file is subject to the Apple OS-Developed Software exception. | |
16 | * | |
17 | * Contents: | |
18 | * | |
19 | * main() - Load the specified language and show the strings for yes and no. | |
20 | */ | |
21 | ||
22 | /* | |
23 | * Include necessary headers... | |
24 | */ | |
25 | ||
26 | #include <stdio.h> | |
27 | #include "i18n.h" | |
7594b224 | 28 | #include "string.h" |
ef416fc2 | 29 | |
30 | ||
31 | /* | |
32 | * 'main()' - Load the specified language and show the strings for yes and no. | |
33 | */ | |
34 | ||
35 | int /* O - Exit status */ | |
36 | main(int argc, /* I - Number of command-line arguments */ | |
37 | char *argv[]) /* I - Command-line arguments */ | |
38 | { | |
7594b224 | 39 | int i; /* Looping var */ |
40 | int errors = 0; /* Number of errors */ | |
ef416fc2 | 41 | cups_lang_t *language; /* Message catalog */ |
42 | cups_lang_t *language2; /* Message catalog */ | |
7594b224 | 43 | struct lconv *loc; /* Locale data */ |
44 | char buffer[1024]; /* String buffer */ | |
45 | double number; /* Number */ | |
46 | static const char * const tests[] = /* Test strings */ | |
47 | { | |
48 | "1", | |
49 | "-1", | |
50 | "3", | |
51 | "5.125" | |
52 | }; | |
53 | ||
ef416fc2 | 54 | |
7594b224 | 55 | _cupsSetLocale(argv); |
ef416fc2 | 56 | |
57 | if (argc == 1) | |
58 | { | |
59 | language = cupsLangDefault(); | |
60 | language2 = cupsLangDefault(); | |
61 | } | |
62 | else | |
63 | { | |
64 | language = cupsLangGet(argv[1]); | |
65 | language2 = cupsLangGet(argv[1]); | |
66 | } | |
67 | ||
68 | if (language != language2) | |
69 | { | |
7594b224 | 70 | errors ++; |
71 | ||
ef416fc2 | 72 | puts("**** ERROR: Language cache did not work! ****"); |
73 | puts("First result from cupsLangGet:"); | |
74 | } | |
75 | ||
76 | printf("Language = \"%s\"\n", language->language); | |
77 | printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding)); | |
78 | printf("No = \"%s\"\n", _cupsLangString(language, "No")); | |
79 | printf("Yes = \"%s\"\n", _cupsLangString(language, "Yes")); | |
80 | ||
81 | if (language != language2) | |
82 | { | |
83 | puts("Second result from cupsLangGet:"); | |
84 | ||
85 | printf("Language = \"%s\"\n", language2->language); | |
86 | printf("Encoding = \"%s\"\n", _cupsEncodingName(language2->encoding)); | |
87 | printf("No = \"%s\"\n", _cupsLangString(language2, "No")); | |
88 | printf("Yes = \"%s\"\n", _cupsLangString(language2, "Yes")); | |
89 | } | |
90 | ||
7594b224 | 91 | loc = localeconv(); |
92 | ||
93 | for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++) | |
94 | { | |
95 | number = _cupsStrScand(tests[i], NULL, loc); | |
96 | ||
97 | printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number); | |
98 | ||
99 | _cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc); | |
100 | ||
101 | printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer); | |
102 | ||
103 | if (strcmp(buffer, tests[i])) | |
104 | { | |
105 | errors ++; | |
106 | puts("**** ERROR: Bad formatted number! ****"); | |
107 | } | |
108 | } | |
109 | ||
110 | return (errors > 0); | |
ef416fc2 | 111 | } |
112 | ||
113 | ||
114 | /* | |
bc44d920 | 115 | * End of "$Id: testlang.c 6649 2007-07-11 21:46:42Z mike $". |
ef416fc2 | 116 | */ |