1 /* Test of quotearg family of functions.
2 Copyright (C) 2008-2011 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Eric Blake <ebb9@byu.net>, 2008. */
34 #include "test-quotearg.h"
38 static struct result_groups locale_results[] = {
39 /* locale_quoting_style */
40 { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
41 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
42 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
43 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
44 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
45 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ},
46 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
47 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ,
48 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } },
50 /* clocale_quoting_style */
51 { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
52 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
53 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
54 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
55 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
56 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
57 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
58 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ,
59 LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } }
62 #endif /* ENABLE_NLS */
65 main (int argc _GL_UNUSED, char *argv[])
67 set_program_name (argv[0]);
70 /* Clean up environment. */
71 unsetenv ("LANGUAGE");
73 unsetenv ("LC_MESSAGES");
74 unsetenv ("LC_CTYPE");
76 unsetenv ("OUTPUT_CHARSET");
78 /* This program part runs in a French UTF-8 locale. It uses
79 the test-quotearg.mo message catalog. */
81 const char *locale_name = getenv ("LOCALE");
83 if (locale_name != NULL && strcmp (locale_name, "none") != 0
84 && setenv ("LC_ALL", locale_name, 1) == 0
85 && setlocale (LC_ALL, "") != NULL)
87 textdomain ("test-quotearg");
88 bindtextdomain ("test-quotearg", getenv ("LOCALEDIR"));
90 set_quoting_style (NULL, locale_quoting_style);
91 compare_strings (use_quotearg_buffer, &locale_results[0].group1, false);
92 compare_strings (use_quotearg, &locale_results[0].group2, false);
93 compare_strings (use_quotearg_colon, &locale_results[0].group3, false);
95 set_quoting_style (NULL, clocale_quoting_style);
96 compare_strings (use_quotearg_buffer, &locale_results[1].group1, false);
97 compare_strings (use_quotearg, &locale_results[1].group2, false);
98 compare_strings (use_quotearg_colon, &locale_results[1].group3, false);
105 fputs ("Skipping test: no french Unicode locale is installed\n", stderr);
108 fputs ("Skipping test: internationalization is disabled\n", stderr);
110 #endif /* ENABLE_NLS */