]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / localization / locale.categories / facet.numpunct / locale.numpunct.byname / grouping.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // REQUIRES: locale.en_US.UTF-8
11 // REQUIRES: locale.fr_FR.UTF-8
12
13 // <locale>
14
15 // template <class charT> class numpunct_byname;
16
17 // string grouping() const;
18
19 #include <locale>
20 #include <cassert>
21
22 #include "test_macros.h"
23 #include "platform_support.h" // locale name macros
24
25 int main()
26 {
27     {
28         std::locale l("C");
29         {
30             typedef char C;
31             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
32             assert(np.grouping() == "");
33         }
34         {
35             typedef wchar_t C;
36             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
37             assert(np.grouping() == "");
38         }
39     }
40     {
41         std::locale l(LOCALE_en_US_UTF_8);
42         {
43             typedef char C;
44             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
45             assert(np.grouping() == "\3\3");
46         }
47         {
48             typedef wchar_t C;
49             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
50             assert(np.grouping() == "\3\3");
51         }
52     }
53     {
54         std::locale l(LOCALE_fr_FR_UTF_8);
55 #if defined(TEST_HAS_GLIBC)
56         const char* const group = "\3";
57 #else
58         const char* const group = "\x7f";
59 #endif
60         {
61             typedef char C;
62             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
63             assert(np.grouping() ==  group);
64         }
65         {
66             typedef wchar_t C;
67             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
68             assert(np.grouping() == group);
69         }
70     }
71 }