spawn: Use special invocation for <spawn.h> on OS/2 kLIBC.
[gnulib.git] / tests / test-quotearg.c
blobccacd93aefd215fcad76d24ef9f8af9ef3f89369
1 /* Test of quotearg family of functions.
2 Copyright (C) 2008-2021 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)
7 any later version.
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, see <https://www.gnu.org/licenses/>. */
17 /* Written by Eric Blake <ebb9@byu.net>, 2008. */
19 #include <config.h>
21 #include "quotearg.h"
23 #include <locale.h>
24 #include <stdbool.h>
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include <string.h>
29 #include "gettext.h"
30 #include "macros.h"
32 #if ENABLE_NLS
34 # include "test-quotearg.h"
36 static struct result_groups locale_results[] = {
37 /* locale_quoting_style */
38 { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
39 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
40 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
41 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
42 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
43 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ},
44 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
45 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ,
46 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } },
48 /* clocale_quoting_style */
49 { { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
50 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
51 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
52 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
53 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a:b" RQ, LQ "a\\\\b" RQ,
54 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ },
55 { LQ RQ, LQ "\\0001\\0" RQ, 11, LQ "simple" RQ,
56 LQ " \\t\\n'\"\\033?""?/\\\\" RQ, LQ "a\\:b" RQ, LQ "a\\\\b" RQ,
57 LQ "a' b" RQ, LQ LQ RQ_ESC RQ, LQ LQ RQ_ESC RQ } }
60 #endif /* ENABLE_NLS */
62 int
63 main (int argc _GL_UNUSED, char *argv[])
65 #if ENABLE_NLS
66 /* Clean up environment. */
67 unsetenv ("LANGUAGE");
68 unsetenv ("LC_ALL");
69 unsetenv ("LC_MESSAGES");
70 unsetenv ("LC_CTYPE");
71 unsetenv ("LANG");
72 unsetenv ("OUTPUT_CHARSET");
74 /* This program part runs in a French UTF-8 locale. It uses
75 the test-quotearg.mo message catalog. */
77 const char *locale_name = getenv ("LOCALE");
79 if (locale_name != NULL && strcmp (locale_name, "none") != 0
80 && setenv ("LC_ALL", locale_name, 1) == 0
81 && setlocale (LC_ALL, "") != NULL)
83 textdomain ("test-quotearg");
84 bindtextdomain ("test-quotearg", getenv ("LOCALEDIR"));
86 set_quoting_style (NULL, locale_quoting_style);
87 compare_strings (use_quotearg_buffer, &locale_results[0].group1, false);
88 compare_strings (use_quotearg, &locale_results[0].group2, false);
89 compare_strings (use_quotearg_colon, &locale_results[0].group3, false);
91 set_quoting_style (NULL, clocale_quoting_style);
92 compare_strings (use_quotearg_buffer, &locale_results[1].group1, false);
93 compare_strings (use_quotearg, &locale_results[1].group2, false);
94 compare_strings (use_quotearg_colon, &locale_results[1].group3, false);
96 quotearg_free ();
97 return 0;
101 fputs ("Skipping test: no french Unicode locale is installed\n", stderr);
102 return 77;
103 #else
104 fputs ("Skipping test: internationalization is disabled\n", stderr);
105 return 77;
106 #endif /* ENABLE_NLS */