ctype_base.pass.cpp revision 0a69fa14d2f0521e45a72068c14fe573b140d48b
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// class ctype_base
13// {
14// public:
15//     typedef T mask;
16//
17//     // numeric values are for exposition only.
18//     static const mask space = 1 << 0;
19//     static const mask print = 1 << 1;
20//     static const mask cntrl = 1 << 2;
21//     static const mask upper = 1 << 3;
22//     static const mask lower = 1 << 4;
23//     static const mask alpha = 1 << 5;
24//     static const mask digit = 1 << 6;
25//     static const mask punct = 1 << 7;
26//     static const mask xdigit = 1 << 8;
27//     static const mask alnum = alpha | digit;
28//     static const mask graph = alnum | punct;
29// };
30
31#include <locale>
32#include <cassert>
33
34template <class _Tp>
35void test(const _Tp &) {}
36
37int main()
38{
39    assert(std::ctype_base::space);
40    assert(std::ctype_base::print);
41    assert(std::ctype_base::cntrl);
42    assert(std::ctype_base::upper);
43    assert(std::ctype_base::lower);
44    assert(std::ctype_base::alpha);
45    assert(std::ctype_base::digit);
46    assert(std::ctype_base::punct);
47    assert(std::ctype_base::xdigit);
48    assert(
49      ( std::ctype_base::space
50      & std::ctype_base::print
51      & std::ctype_base::cntrl
52      & std::ctype_base::upper
53      & std::ctype_base::lower
54      & std::ctype_base::alpha
55      & std::ctype_base::digit
56      & std::ctype_base::punct
57      & std::ctype_base::xdigit) == 0);
58    assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
59    assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
60
61    test(std::ctype_base::space);
62    test(std::ctype_base::print);
63    test(std::ctype_base::cntrl);
64    test(std::ctype_base::upper);
65    test(std::ctype_base::lower);
66    test(std::ctype_base::alpha);
67    test(std::ctype_base::digit);
68    test(std::ctype_base::punct);
69    test(std::ctype_base::xdigit);
70    test(std::ctype_base::blank);
71    test(std::ctype_base::alnum);
72    test(std::ctype_base::graph);
73}
74