]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/testlang.c
Update svn:keyword properties.
[thirdparty/cups.git] / cups / testlang.c
CommitLineData
ef416fc2 1/*
f2d18633 2 * "$Id$"
ef416fc2 3 *
71e16022 4 * Localization test program for CUPS.
ef416fc2 5 *
71e16022 6 * Copyright 2007-2010 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
71e16022 26#include "cups-private.h"
ef416fc2 27
28
29/*
30 * 'main()' - Load the specified language and show the strings for yes and no.
31 */
32
33int /* O - Exit status */
34main(int argc, /* I - Number of command-line arguments */
35 char *argv[]) /* I - Command-line arguments */
36{
7594b224 37 int i; /* Looping var */
38 int errors = 0; /* Number of errors */
ef416fc2 39 cups_lang_t *language; /* Message catalog */
40 cups_lang_t *language2; /* Message catalog */
7594b224 41 struct lconv *loc; /* Locale data */
42 char buffer[1024]; /* String buffer */
43 double number; /* Number */
44 static const char * const tests[] = /* Test strings */
45 {
46 "1",
47 "-1",
48 "3",
49 "5.125"
50 };
51
ef416fc2 52
7594b224 53 _cupsSetLocale(argv);
ef416fc2 54
55 if (argc == 1)
56 {
57 language = cupsLangDefault();
58 language2 = cupsLangDefault();
59 }
60 else
61 {
62 language = cupsLangGet(argv[1]);
63 language2 = cupsLangGet(argv[1]);
64 }
65
66 if (language != language2)
67 {
7594b224 68 errors ++;
69
ef416fc2 70 puts("**** ERROR: Language cache did not work! ****");
71 puts("First result from cupsLangGet:");
72 }
73
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"));
78
79 if (language != language2)
80 {
81 puts("Second result from cupsLangGet:");
82
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"));
87 }
88
7594b224 89 loc = localeconv();
90
91 for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i ++)
92 {
93 number = _cupsStrScand(tests[i], NULL, loc);
94
95 printf("_cupsStrScand(\"%s\") number=%f\n", tests[i], number);
96
97 _cupsStrFormatd(buffer, buffer + sizeof(buffer), number, loc);
98
99 printf("_cupsStrFormatd(%f) buffer=\"%s\"\n", number, buffer);
100
101 if (strcmp(buffer, tests[i]))
102 {
103 errors ++;
104 puts("**** ERROR: Bad formatted number! ****");
105 }
106 }
107
108 return (errors > 0);
ef416fc2 109}
110
111
112/*
f2d18633 113 * End of "$Id$".
ef416fc2 114 */