VirtualBox

source: kBuild/vendor/grep/2.12/gnulib-tests/test-nl_langinfo.c@ 3627

Last change on this file since 3627 was 2595, checked in by bird, 13 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1/* Test of nl_langinfo replacement.
2 Copyright (C) 2009-2012 Free Software Foundation, Inc.
3
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 of the License, or
7 (at your option) any later version.
8
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.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2009. */
18
19#include <config.h>
20
21#include <langinfo.h>
22
23#include "signature.h"
24SIGNATURE_CHECK (nl_langinfo, char *, (nl_item));
25
26#include <locale.h>
27#include <stdlib.h>
28#include <string.h>
29
30#include "c-strcase.h"
31#include "macros.h"
32
33/* For GCC >= 4.3, silence the warnings
34 "comparison of unsigned expression >= 0 is always true"
35 in this file. */
36#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
37# pragma GCC diagnostic ignored "-Wtype-limits"
38#endif
39
40int
41main (int argc, char *argv[])
42{
43 int pass = atoi (argv[1]);
44 /* pass locale
45 0 C
46 1 traditional French locale
47 2 French UTF-8 locale
48 */
49
50 setlocale (LC_ALL, "");
51
52 /* nl_langinfo items of the LC_CTYPE category */
53 ASSERT (strlen (nl_langinfo (CODESET)) > 0);
54 if (pass == 2)
55 {
56 const char *codeset = nl_langinfo (CODESET);
57 ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0);
58 }
59 /* nl_langinfo items of the LC_NUMERIC category */
60 ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0);
61 ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0);
62 /* nl_langinfo items of the LC_TIME category */
63 ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0);
64 ASSERT (strlen (nl_langinfo (D_FMT)) > 0);
65 ASSERT (strlen (nl_langinfo (T_FMT)) > 0);
66 ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0));
67 ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0));
68 ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0));
69 ASSERT (strlen (nl_langinfo (DAY_1)) > 0);
70 ASSERT (strlen (nl_langinfo (DAY_2)) > 0);
71 ASSERT (strlen (nl_langinfo (DAY_3)) > 0);
72 ASSERT (strlen (nl_langinfo (DAY_4)) > 0);
73 ASSERT (strlen (nl_langinfo (DAY_5)) > 0);
74 ASSERT (strlen (nl_langinfo (DAY_6)) > 0);
75 ASSERT (strlen (nl_langinfo (DAY_7)) > 0);
76 ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0);
77 ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0);
78 ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0);
79 ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0);
80 ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0);
81 ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0);
82 ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0);
83 ASSERT (strlen (nl_langinfo (MON_1)) > 0);
84 ASSERT (strlen (nl_langinfo (MON_2)) > 0);
85 ASSERT (strlen (nl_langinfo (MON_3)) > 0);
86 ASSERT (strlen (nl_langinfo (MON_4)) > 0);
87 ASSERT (strlen (nl_langinfo (MON_5)) > 0);
88 ASSERT (strlen (nl_langinfo (MON_6)) > 0);
89 ASSERT (strlen (nl_langinfo (MON_7)) > 0);
90 ASSERT (strlen (nl_langinfo (MON_8)) > 0);
91 ASSERT (strlen (nl_langinfo (MON_9)) > 0);
92 ASSERT (strlen (nl_langinfo (MON_10)) > 0);
93 ASSERT (strlen (nl_langinfo (MON_11)) > 0);
94 ASSERT (strlen (nl_langinfo (MON_12)) > 0);
95 ASSERT (strlen (nl_langinfo (ABMON_1)) > 0);
96 ASSERT (strlen (nl_langinfo (ABMON_2)) > 0);
97 ASSERT (strlen (nl_langinfo (ABMON_3)) > 0);
98 ASSERT (strlen (nl_langinfo (ABMON_4)) > 0);
99 ASSERT (strlen (nl_langinfo (ABMON_5)) > 0);
100 ASSERT (strlen (nl_langinfo (ABMON_6)) > 0);
101 ASSERT (strlen (nl_langinfo (ABMON_7)) > 0);
102 ASSERT (strlen (nl_langinfo (ABMON_8)) > 0);
103 ASSERT (strlen (nl_langinfo (ABMON_9)) > 0);
104 ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
105 ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
106 ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
107 ASSERT (strlen (nl_langinfo (ERA)) >= 0);
108 ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
109 ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);
110 ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0);
111 ASSERT (nl_langinfo (ALT_DIGITS) != NULL);
112 /* nl_langinfo items of the LC_MONETARY category */
113 {
114 const char *currency = nl_langinfo (CRNCYSTR);
115 ASSERT (strlen (currency) >= 0);
116#if !defined __NetBSD__
117 if (pass > 0)
118 ASSERT (strlen (currency) >= 1);
119#endif
120 }
121 /* nl_langinfo items of the LC_MESSAGES category */
122 ASSERT (strlen (nl_langinfo (YESEXPR)) > 0);
123 ASSERT (strlen (nl_langinfo (NOEXPR)) > 0);
124
125 return 0;
126}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette