1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class charT> struct regex_traits;
14 // int value(charT ch, int radix) const;
22 std::regex_traits
<char> t
;
24 for (char c
= 0; c
< '0'; ++c
)
26 assert(t
.value(c
, 8) == -1);
27 assert(t
.value(c
, 10) == -1);
28 assert(t
.value(c
, 16) == -1);
30 for (char c
= '0'; c
< '8'; ++c
)
32 assert(t
.value(c
, 8) == c
- '0');
33 assert(t
.value(c
, 10) == c
- '0');
34 assert(t
.value(c
, 16) == c
- '0');
36 for (char c
= '8'; c
< ':'; ++c
)
38 assert(t
.value(c
, 8) == -1);
39 assert(t
.value(c
, 10) == c
- '0');
40 assert(t
.value(c
, 16) == c
- '0');
42 for (char c
= ':'; c
< 'A'; ++c
)
44 assert(t
.value(c
, 8) == -1);
45 assert(t
.value(c
, 10) == -1);
46 assert(t
.value(c
, 16) == -1);
48 for (char c
= 'A'; c
< 'G'; ++c
)
50 assert(t
.value(c
, 8) == -1);
51 assert(t
.value(c
, 10) == -1);
52 assert(t
.value(c
, 16) == c
- 'A' +10);
54 for (char c
= 'G'; c
< 'a'; ++c
)
56 assert(t
.value(c
, 8) == -1);
57 assert(t
.value(c
, 10) == -1);
58 assert(t
.value(c
, 16) == -1);
60 for (char c
= 'a'; c
< 'g'; ++c
)
62 assert(t
.value(c
, 8) == -1);
63 assert(t
.value(c
, 10) == -1);
64 assert(t
.value(c
, 16) == c
- 'a' +10);
66 for (int c
= 'g'; c
< 256; ++c
)
68 assert(t
.value(char(c
), 8) == -1);
69 assert(t
.value(char(c
), 10) == -1);
70 assert(t
.value(char(c
), 16) == -1);
74 std::regex_traits
<wchar_t> t
;
76 for (wchar_t c
= 0; c
< '0'; ++c
)
78 assert(t
.value(c
, 8) == -1);
79 assert(t
.value(c
, 10) == -1);
80 assert(t
.value(c
, 16) == -1);
82 for (wchar_t c
= '0'; c
< '8'; ++c
)
84 assert(t
.value(c
, 8) == c
- '0');
85 assert(t
.value(c
, 10) == c
- '0');
86 assert(t
.value(c
, 16) == c
- '0');
88 for (wchar_t c
= '8'; c
< ':'; ++c
)
90 assert(t
.value(c
, 8) == -1);
91 assert(t
.value(c
, 10) == c
- '0');
92 assert(t
.value(c
, 16) == c
- '0');
94 for (wchar_t c
= ':'; c
< 'A'; ++c
)
96 assert(t
.value(c
, 8) == -1);
97 assert(t
.value(c
, 10) == -1);
98 assert(t
.value(c
, 16) == -1);
100 for (wchar_t c
= 'A'; c
< 'G'; ++c
)
102 assert(t
.value(c
, 8) == -1);
103 assert(t
.value(c
, 10) == -1);
104 assert(t
.value(c
, 16) == c
- 'A' +10);
106 for (wchar_t c
= 'G'; c
< 'a'; ++c
)
108 assert(t
.value(c
, 8) == -1);
109 assert(t
.value(c
, 10) == -1);
110 assert(t
.value(c
, 16) == -1);
112 for (wchar_t c
= 'a'; c
< 'g'; ++c
)
114 assert(t
.value(c
, 8) == -1);
115 assert(t
.value(c
, 10) == -1);
116 assert(t
.value(c
, 16) == c
- 'a' +10);
118 for (int c
= 'g'; c
< 0xFFFF; ++c
)
120 assert(t
.value(c
, 8) == -1);
121 assert(t
.value(c
, 10) == -1);
122 assert(t
.value(c
, 16) == -1);