File: test-nl_langinfo.c

package info (click to toggle)
libprelude 1.0.0-11.9
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 24,456 kB
  • ctags: 17,851
  • sloc: ansic: 190,841; cpp: 38,769; xml: 30,141; sh: 11,668; makefile: 692; python: 481; awk: 341; yacc: 238; lex: 186; perl: 5
file content (115 lines) | stat: -rw-r--r-- 4,365 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* Test of nl_langinfo replacement.
   Copyright (C) 2009, 2010 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* Written by Bruno Haible <bruno@clisp.org>, 2009.  */

#include <config.h>

#include <langinfo.h>

#include "signature.h"
SIGNATURE_CHECK (nl_langinfo, char *, (nl_item));

#include <locale.h>
#include <stdlib.h>
#include <string.h>

#include "c-strcase.h"
#include "macros.h"

int
main (int argc, char *argv[])
{
  int pass = atoi (argv[1]);
  /* pass    locale
      0        C
      1        traditional French locale
      2        French UTF-8 locale
   */

  setlocale (LC_ALL, "");

  /* nl_langinfo items of the LC_CTYPE category */
  ASSERT (strlen (nl_langinfo (CODESET)) > 0);
  if (pass == 2)
    {
      const char *codeset = nl_langinfo (CODESET);
      ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0);
    }
  /* nl_langinfo items of the LC_NUMERIC category */
  ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0);
  ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0);
  /* nl_langinfo items of the LC_TIME category */
  ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0);
  ASSERT (strlen (nl_langinfo (D_FMT)) > 0);
  ASSERT (strlen (nl_langinfo (T_FMT)) > 0);
  ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0));
  ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0));
  ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0));
  ASSERT (strlen (nl_langinfo (DAY_1)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_2)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_3)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_4)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_5)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_6)) > 0);
  ASSERT (strlen (nl_langinfo (DAY_7)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0);
  ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0);
  ASSERT (strlen (nl_langinfo (MON_1)) > 0);
  ASSERT (strlen (nl_langinfo (MON_2)) > 0);
  ASSERT (strlen (nl_langinfo (MON_3)) > 0);
  ASSERT (strlen (nl_langinfo (MON_4)) > 0);
  ASSERT (strlen (nl_langinfo (MON_5)) > 0);
  ASSERT (strlen (nl_langinfo (MON_6)) > 0);
  ASSERT (strlen (nl_langinfo (MON_7)) > 0);
  ASSERT (strlen (nl_langinfo (MON_8)) > 0);
  ASSERT (strlen (nl_langinfo (MON_9)) > 0);
  ASSERT (strlen (nl_langinfo (MON_10)) > 0);
  ASSERT (strlen (nl_langinfo (MON_11)) > 0);
  ASSERT (strlen (nl_langinfo (MON_12)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_1)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_2)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_3)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_4)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_5)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_6)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_7)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_8)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_9)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
  ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
  ASSERT (strlen (nl_langinfo (ERA)) >= 0);
  ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
  ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);
  ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0);
  ASSERT (nl_langinfo (ALT_DIGITS) != NULL);
  /* nl_langinfo items of the LC_MONETARY category */
  {
    const char *currency = nl_langinfo (CRNCYSTR);
    ASSERT (strlen (currency) >= (pass > 0 ? 1 : 0));
  }
  /* nl_langinfo items of the LC_MESSAGES category */
  ASSERT (strlen (nl_langinfo (YESEXPR)) > 0);
  ASSERT (strlen (nl_langinfo (NOEXPR)) > 0);

  return 0;
}