Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
IntTypes.ut.cpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2013-2019 Swirly Cloud Limited
3// Copyright (C) 2021 Reactive Markets Limited
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17#include "IntTypes.hpp"
18
19#include <boost/test/unit_test.hpp>
20
21#include <boost/lexical_cast.hpp>
22
23using namespace boost;
24using namespace std;
25using namespace toolbox;
26
27namespace {
28
29struct TestTag : Int32Policy {};
31
32constexpr Test operator""_test(unsigned long long val) noexcept
33{
34 return Test{val};
35}
36
37} // namespace
38
40
47
54
61
68
75
77{
78 // 11100
79 // 00111
80 // 00100
81 auto x = 28_test;
84}
85
87{
88 // 11100
89 // 00111
90 // 11111
91 auto x = 28_test;
94}
95
97{
98 // 11100
99 // 00111
100 // 11011
101 auto x = 28_test;
102 BOOST_CHECK_EQUAL((x ^= 7_test), 27_test);
104}
105
107{
108 // 00111
109 // 11100
110 auto x = 7_test;
111 BOOST_CHECK_EQUAL((x <<= 2_test), 28_test);
113}
114
116{
117 // 11100
118 // 00111
119 auto x = 28_test;
120 BOOST_CHECK_EQUAL((x >>= 2_test), 7_test);
122}
123
130
137
144
151
153{
154 constexpr auto x = 5_test;
156}
157
159{
160 constexpr auto x = 5_test;
162}
163
165{
166 constexpr auto x = 5_test;
168}
169
171{
172 constexpr auto x = 5_test;
174}
175
177{
178 constexpr auto x = 5_test;
180}
181
183{
184 constexpr auto x = 15_test;
186}
187
189{
190 constexpr auto x = 5_test;
192}
193
195{
196 constexpr auto x = Test{~1};
198}
199
201{
202 // 11100
203 // 00111
204 // 00100
205 constexpr auto x = 28_test;
207}
208
210{
211 // 11100
212 // 00111
213 // 11111
214 constexpr auto x = 28_test;
216}
217
219{
220 // 11100
221 // 00111
222 // 11011
223 constexpr auto x = 28_test;
225}
226
228{
229 // 00111
230 // 11100
231 constexpr auto x = 7_test;
232 BOOST_CHECK_EQUAL((x << 2_test), 28_test);
233}
234
236{
237 // 11100
238 // 00111
239 constexpr auto x = 28_test;
241}
242
247
252
257
262
268
274
279
BOOST_AUTO_TEST_CASE(IntAddAssignCase)
BOOST_CHECK_EQUAL(v.size(), 10U)
STL namespace.
constexpr auto bind() noexcept
Definition Slot.hpp:92