1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// TODO(mordante) Investigate
10// UNSUPPORTED: apple-clang
11
12// NetBSD does not support LC_NUMERIC at the moment
13// XFAIL: netbsd
14
15// XFAIL: LIBCXX-FREEBSD-FIXME
16
17// REQUIRES: locale.en_US.UTF-8
18// REQUIRES: locale.fr_FR.UTF-8
19
20// <locale>
21
22// template <class charT> class numpunct_byname;
23
24// string grouping() const;
25
26#include <locale>
27#include <cassert>
28
29#include "test_macros.h"
30#include "platform_support.h" // locale name macros
31
32int main(int, char**)
33{
34 {
35 std::locale l("C");
36 {
37 typedef char C;
38 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(loc: l);
39 assert(np.grouping() == "");
40 }
41#ifndef TEST_HAS_NO_WIDE_CHARACTERS
42 {
43 typedef wchar_t C;
44 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(loc: l);
45 assert(np.grouping() == "");
46 }
47#endif
48 }
49 {
50 std::locale l(LOCALE_en_US_UTF_8);
51 {
52 typedef char C;
53 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
54 assert(np.grouping() == "\3" || np.grouping() == "\3\3");
55 }
56#ifndef TEST_HAS_NO_WIDE_CHARACTERS
57 {
58 typedef wchar_t C;
59 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
60 assert(np.grouping() == "\3" || np.grouping() == "\3\3");
61 }
62#endif
63 }
64 {
65 std::locale l(LOCALE_fr_FR_UTF_8);
66#if defined(TEST_HAS_GLIBC) || defined(_WIN32) || defined(_AIX)
67 const char* const group = "\3";
68#else
69 const char* const group = "\x7f";
70#endif
71 {
72 typedef char C;
73 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
74 assert(np.grouping() == group);
75 }
76#ifndef TEST_HAS_NO_WIDE_CHARACTERS
77 {
78 typedef wchar_t C;
79 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
80 assert(np.grouping() == group);
81 }
82#endif
83 }
84
85 return 0;
86}
87

source code of libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp