[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / re / re.traits / value.pass.cpp
blobb7ca1fb7c07a4f818fe59b0aa9cfbc4fa7611d46
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 //===----------------------------------------------------------------------===//
9 // <regex>
11 // template <class charT> struct regex_traits;
13 // int value(charT ch, int radix) const;
15 #include <regex>
16 #include <cassert>
17 #include "test_macros.h"
19 int main(int, char**)
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) == static_cast<int>(c - '0'));
85 assert(t.value(c, 10) == static_cast<int>(c - '0'));
86 assert(t.value(c, 16) == static_cast<int>(c - '0'));
88 for (wchar_t c = '8'; c < ':'; ++c)
90 assert(t.value(c, 8) == -1);
91 assert(t.value(c, 10) == static_cast<int>(c - '0'));
92 assert(t.value(c, 16) == static_cast<int>(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) == static_cast<int>(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) == static_cast<int>(c - 'a' +10));
118 for (wchar_t 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);
126 return 0;