grouping.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// <locale>
11
12// template <class charT> class numpunct_byname;
13
14// string grouping() const;
15
16#include <locale>
17#include <cassert>
18
19int main()
20{
21    {
22        std::locale l("C");
23        {
24            typedef char C;
25            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
26            assert(np.grouping() == "");
27        }
28        {
29            typedef wchar_t C;
30            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
31            assert(np.grouping() == "");
32        }
33    }
34    {
35        std::locale l("en_US");
36        {
37            typedef char C;
38            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
39            assert(np.grouping() == "\3\3");
40        }
41        {
42            typedef wchar_t C;
43            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
44            assert(np.grouping() == "\3\3");
45        }
46    }
47    {
48        std::locale l("fr_FR");
49        {
50            typedef char C;
51            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
52            assert(np.grouping() == "\x7F");
53        }
54        {
55            typedef wchar_t C;
56            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
57            assert(np.grouping() == "\x7F");
58        }
59    }
60}
61