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// NetBSD does not support LC_NUMERIC at the moment
10// XFAIL: netbsd
11
12// XFAIL: LIBCXX-AIX-FIXME
13// XFAIL: LIBCXX-FREEBSD-FIXME
14
15// REQUIRES: locale.en_US.UTF-8
16// REQUIRES: locale.fr_FR.UTF-8
17
18// <locale>
19
20// template <class charT> class numpunct_byname;
21
22// string grouping() const;
23
24#include <locale>
25#include <cassert>
26
27#include "test_macros.h"
28#include "platform_support.h" // locale name macros
29
30int main(int, char**)
31{
32 {
33 std::locale l("C");
34 {
35 typedef char C;
36 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(loc: l);
37 assert(np.grouping() == "");
38 }
39#ifndef TEST_HAS_NO_WIDE_CHARACTERS
40 {
41 typedef wchar_t C;
42 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(loc: l);
43 assert(np.grouping() == "");
44 }
45#endif
46 }
47 {
48 std::locale l(LOCALE_en_US_UTF_8);
49 {
50 typedef char C;
51 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
52#ifdef _WIN32
53 assert(np.grouping() == "\3");
54#else
55 assert(np.grouping() == "\3\3");
56#endif
57 }
58#ifndef TEST_HAS_NO_WIDE_CHARACTERS
59 {
60 typedef wchar_t C;
61 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
62#ifdef _WIN32
63 assert(np.grouping() == "\3");
64#else
65 assert(np.grouping() == "\3\3");
66#endif
67 }
68#endif
69 }
70 {
71 std::locale l(LOCALE_fr_FR_UTF_8);
72#if defined(TEST_HAS_GLIBC) || defined(_WIN32)
73 const char* const group = "\3";
74#else
75 const char* const group = "\x7f";
76#endif
77 {
78 typedef char C;
79 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
80 assert(np.grouping() == group);
81 }
82#ifndef TEST_HAS_NO_WIDE_CHARACTERS
83 {
84 typedef wchar_t C;
85 const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
86 assert(np.grouping() == group);
87 }
88#endif
89 }
90
91 return 0;
92}
93

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