DUNE PDELab (git)

arithmetictestsuite.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_COMMON_TEST_ARITHMETICTESTSUITE_HH
6#define DUNE_COMMON_TEST_ARITHMETICTESTSUITE_HH
7
8#include <string>
9#include <type_traits>
10#include <utility>
11
13#include <dune/common/test/testsuite.hh>
14
15namespace Dune {
16
17/*
18 * silence warnings from GCC about using integer operands on a bool
19 * (when instantiated for T=bool)
20 */
21#if __GNUC__ >= 7
22# pragma GCC diagnostic push
23# pragma GCC diagnostic ignored "-Wbool-operation"
24# pragma GCC diagnostic ignored "-Wint-in-bool-context"
25# define GCC_WARNING_DISABLED
26#endif
27
28/*
29 * silence warnings from Clang about using bitwise operands on
30 * a bool (when instantiated for T=bool)
31 */
32#ifdef __clang__
33# pragma clang diagnostic push
34# pragma clang diagnostic ignored "-Wbool-operation"
35# define CLANG_WARNING_DISABLED
36#endif
37
39
44 public TestSuite
45 {
46 public:
47 // inherit all constructors from TestSuite
49
51 struct Arithmetic {};
53 struct Integral : Arithmetic {};
55 struct Boolean : Integral {};
57 struct Signed : Integral {};
59 struct Unsigned : Integral {};
61 struct Floating : Arithmetic {};
62
63 private:
64 static const char *name(Arithmetic) { return "Arithmetic"; }
65 static const char *name(Integral ) { return "Integral"; }
66 static const char *name(Boolean ) { return "Boolean"; }
67 static const char *name(Signed ) { return "Signed"; }
68 static const char *name(Unsigned ) { return "Unsigned"; }
69 static const char *name(Floating ) { return "Floating"; }
70
71 template<class C, class Then, class Else = void>
72 using Cond = typename std::conditional<C::value, Then, Else>::type;
73
74 public:
76
82 template<class T>
83 constexpr static auto tag(T = T{})
84 {
85 return
86 Cond<std::is_convertible<T, Arithmetic>, T,
87 Cond<std::is_floating_point<T>, Floating,
88 Cond<std::is_integral<T>,
89 Cond<std::is_same<bool, T>, Boolean,
90 Cond<std::is_signed<T>, Signed,
91 Cond<std::is_unsigned<T>, Unsigned
92 > > >
93 > > >{};
94 }
95
96#define DUNE_TEST_FUNCTION(T, tag) \
97 static const auto function = \
98 std::string(__func__) + "<" + className<T>() + ">(" + name(tag) + ")"
99
100#define DUNE_TEST_CHECK(expr) \
101 (check((expr), function) \
102 << __FILE__ << ":" << __LINE__ << ": Check \"" << #expr << "\"")
103
104 //
105 // check basic operations: construct, copy, compare
106 //
107
109 template<class T>
110 void checkDefaultConstruct([[maybe_unused]] Arithmetic arithmetic_tag)
111 {
112 [[maybe_unused]] T t0;
113 (void)T();
114 [[maybe_unused]] T t1{};
115 [[maybe_unused]] T t2 = {};
116 }
117
119 template<class T>
121 {
122 DUNE_TEST_FUNCTION(T, arithmetic_tag);
123 // this test may be applied to boolean-type types. 0 and 1 are the only
124 // values that survive that.
125 T t0(0); DUNE_TEST_CHECK(int(t0) == 0);
126 T t1(1); DUNE_TEST_CHECK(int(t1) == 1);
127 }
128
130 template<class T>
131 void checkMoveConstruct(Arithmetic arithmetic_tag)
132 {
133 DUNE_TEST_FUNCTION(T, arithmetic_tag);
134 for(int i : { 0, 1 })
135 {
136 T t0(i);
137
138 T t1(std::move(t0));
139 T t2 = std::move(t1);
140 T t3{ std::move(t2) };
141 T t4 = { std::move(t3) };
142
143 DUNE_TEST_CHECK(bool(t4 == T(i)));
144 }
145 }
146
148 template<class T>
149 void checkCopyConstruct(Arithmetic arithmetic_tag)
150 {
151 DUNE_TEST_FUNCTION(T, arithmetic_tag);
152 for(int i : { 0, 1 })
153 {
154 T t0(i);
155
156 T t1(t0);
157 T t2 = t1;
158 T t3{ t2 };
159 T t4 = { t3 };
160
161 DUNE_TEST_CHECK(bool(t0 == T(i)));
162 DUNE_TEST_CHECK(bool(t1 == T(i)));
163 DUNE_TEST_CHECK(bool(t2 == T(i)));
164 DUNE_TEST_CHECK(bool(t3 == T(i)));
165 DUNE_TEST_CHECK(bool(t4 == T(i)));
166 }
167 }
168
170 template<class T>
171 void checkMoveAssign(Arithmetic arithmetic_tag)
172 {
173 DUNE_TEST_FUNCTION(T, arithmetic_tag);
174 for(int i : { 0, 1 })
175 {
176 T t0(i);
177 T t2, t4;
178
179 t2 = std::move(t0);
180 t4 = { std::move(t2) };
181
182 DUNE_TEST_CHECK(bool(t4 == T(i)));
183 }
184 }
185
187 template<class T>
188 void checkCopyAssign(Arithmetic arithmetic_tag)
189 {
190 DUNE_TEST_FUNCTION(T, arithmetic_tag);
191 for(int i : { 0, 1 })
192 {
193 T t0(i);
194 T t2, t4;
195
196 t2 = t0;
197 t4 = { t2 };
198
199 DUNE_TEST_CHECK(bool(t0 == T(i)));
200 DUNE_TEST_CHECK(bool(t2 == T(i)));
201 DUNE_TEST_CHECK(bool(t4 == T(i)));
202 }
203 }
204
206
210 template<class T>
211 void checkEqual(Arithmetic arithmetic_tag)
212 {
213 DUNE_TEST_FUNCTION(T, arithmetic_tag);
214 T t0(0);
215 T t1(1);
216
217 DUNE_TEST_CHECK(bool(t0 == T(0)));
218 DUNE_TEST_CHECK(bool(t1 == T(1)));
219
220 DUNE_TEST_CHECK(!bool(t0 == T(1)));
221 DUNE_TEST_CHECK(!bool(t1 == T(0)));
222 DUNE_TEST_CHECK(!bool(t0 == t1));
223
224 DUNE_TEST_CHECK(!bool(t0 != T(0)));
225 DUNE_TEST_CHECK(!bool(t1 != T(1)));
226
227 DUNE_TEST_CHECK(bool(t0 != T(1)));
228 DUNE_TEST_CHECK(bool(t1 != T(0)));
229 DUNE_TEST_CHECK(bool(t0 != t1));
230 }
231
232 //
233 // checks for unary operators
234 //
235
237
240 template<class T>
241 void checkPostfixInc(Arithmetic arithmetic_tag)
242 {
243 DUNE_TEST_FUNCTION(T, arithmetic_tag);
244
245 T t0(0);
246 DUNE_TEST_CHECK(bool(T(t0++) == T(0)));
247 DUNE_TEST_CHECK(bool(t0 == T(1)));
248 }
249 template<class T>
250 void checkPostfixInc(Boolean) {}
251
253
256 template<class T>
257 void checkPostfixDec(Arithmetic arithmetic_tag)
258 {
259 DUNE_TEST_FUNCTION(T, arithmetic_tag);
260
261 T t1(1);
262 DUNE_TEST_CHECK(bool(T(t1--) == T(1)));
263 DUNE_TEST_CHECK(bool(t1 == T(0)));
264 }
265 template<class T>
266 void checkPostfixDec(Boolean) {}
267
269
272 template<class T>
273 void checkPrefixPlus(Arithmetic arithmetic_tag)
274 {
275 DUNE_TEST_FUNCTION(T, arithmetic_tag);
276
277 DUNE_TEST_CHECK(bool(T(+T(0)) == T(0)));
278 DUNE_TEST_CHECK(bool(T(+T(1)) == T(1)));
279 }
280
282
285 template<class T>
286 void checkPrefixMinus(Arithmetic arithmetic_tag)
287 {
288 DUNE_TEST_FUNCTION(T, arithmetic_tag);
289
290 DUNE_TEST_CHECK(bool(T(-T(0)) == T( 0)));
291 DUNE_TEST_CHECK(bool(T(-T(1)) == T(-1)));
292 }
293
295
298 template<class T>
299 void checkPrefixNot(Arithmetic arithmetic_tag)
300 {
301 DUNE_TEST_FUNCTION(T, arithmetic_tag);
302
303 DUNE_TEST_CHECK(bool(!T(0)));
304 DUNE_TEST_CHECK(!bool(!T(1)));
305 }
306
308
311 template<class T>
312 void checkPrefixBitNot(Boolean arithmetic_tag)
313 {
314 DUNE_TEST_FUNCTION(T, arithmetic_tag);
315
316 DUNE_TEST_CHECK(bool(T(~T(0))));
317 }
318 template<class T>
319 void checkPrefixBitNot(Integral arithmetic_tag)
320 {
321 DUNE_TEST_FUNCTION(T, arithmetic_tag);
322
323 DUNE_TEST_CHECK(bool(T(~T(0))));
324 DUNE_TEST_CHECK(bool(T(~T(1))));
325
326 DUNE_TEST_CHECK(bool(T(~T(~T(0))) == T(0)));
327 DUNE_TEST_CHECK(bool(T(~T(~T(1))) == T(1)));
328 }
329 template<class T>
330 void checkPrefixBitNot(Unsigned arithmetic_tag)
331 {
332 DUNE_TEST_FUNCTION(T, arithmetic_tag);
333
334 checkPrefixBitNot<T>(Integral{});
335
336 DUNE_TEST_CHECK(bool(T(~T(0)) == T(-1)));
337 DUNE_TEST_CHECK(bool(T(~T(1)) == T(-2)));
338 }
339 template<class T>
340 void checkPrefixBitNot(Floating) {}
341
343
346 template<class T>
347 void checkPrefixInc(Arithmetic arithmetic_tag)
348 {
349 DUNE_TEST_FUNCTION(T, arithmetic_tag);
350
351 T t0(0);
352 DUNE_TEST_CHECK(bool(T(++t0) == T(1)));
353 DUNE_TEST_CHECK(bool(t0 == T(1)));
354 ++t0 = T(0);
355 DUNE_TEST_CHECK(bool(t0 == T(0)));
356 }
357 template<class T>
358 void checkPrefixInc(Boolean) {}
359
361
364 template<class T>
365 void checkPrefixDec(Arithmetic arithmetic_tag)
366 {
367 DUNE_TEST_FUNCTION(T, arithmetic_tag);
368
369 T t1(1);
370 DUNE_TEST_CHECK(bool(T(--t1) == T(0)));
371 DUNE_TEST_CHECK(bool(t1 == T(0)));
372 t1 = T(1);
373 --t1 = T(1);
374 DUNE_TEST_CHECK(bool(t1 == T(1)));
375 }
376 template<class T>
377 void checkPrefixDec(Boolean) {}
378
379 //
380 // checks for infox operators
381 //
382
384
387 template<class T>
388 void checkInfixMul(Arithmetic arithmetic_tag)
389 {
390 DUNE_TEST_FUNCTION(T, arithmetic_tag);
391
392 DUNE_TEST_CHECK(bool(T(T(0)*T(0)) == T(0)));
393 DUNE_TEST_CHECK(bool(T(T(1)*T(0)) == T(0)));
394 DUNE_TEST_CHECK(bool(T(T(0)*T(1)) == T(0)));
395 DUNE_TEST_CHECK(bool(T(T(1)*T(1)) == T(1)));
396 }
397
399
402 template<class T>
403 void checkInfixDiv(Arithmetic arithmetic_tag)
404 {
405 DUNE_TEST_FUNCTION(T, arithmetic_tag);
406
407 DUNE_TEST_CHECK(bool(T(T(0)/T(1)) == T(0)));
408 DUNE_TEST_CHECK(bool(T(T(1)/T(1)) == T(1)));
409 }
410
412
415 template<class T>
416 void checkInfixRem(Arithmetic arithmetic_tag)
417 {
418 DUNE_TEST_FUNCTION(T, arithmetic_tag);
419
420 DUNE_TEST_CHECK(bool(T(T(0)%T(1)) == T(0)));
421 DUNE_TEST_CHECK(bool(T(T(1)%T(1)) == T(0)));
422 }
423 template<class T>
424 void checkInfixRem(Floating) {}
425
427
430 template<class T>
431 void checkInfixPlus(Arithmetic arithmetic_tag)
432 {
433 DUNE_TEST_FUNCTION(T, arithmetic_tag);
434
435 DUNE_TEST_CHECK(bool(T(T(0)+T(0)) == T(0)));
436 DUNE_TEST_CHECK(bool(T(T(1)+T(0)) == T(1)));
437 DUNE_TEST_CHECK(bool(T(T(0)+T(1)) == T(1)));
438 DUNE_TEST_CHECK(bool(T(T(1)+T(1)) == T(2)));
439 }
440
442
445 template<class T>
446 void checkInfixMinus(Arithmetic arithmetic_tag)
447 {
448 DUNE_TEST_FUNCTION(T, arithmetic_tag);
449
450 DUNE_TEST_CHECK(bool(T(T(0)-T(0)) == T( 0)));
451 DUNE_TEST_CHECK(bool(T(T(1)-T(0)) == T( 1)));
452 DUNE_TEST_CHECK(bool(T(T(0)-T(1)) == T(-1)));
453 DUNE_TEST_CHECK(bool(T(T(1)-T(1)) == T( 0)));
454 }
455
457
460 template<class T>
461 void checkInfixLShift(Arithmetic arithmetic_tag)
462 {
463 DUNE_TEST_FUNCTION(T, arithmetic_tag);
464
465 DUNE_TEST_CHECK(bool(T(T(0)<<T(0)) == T(0)));
466 DUNE_TEST_CHECK(bool(T(T(1)<<T(0)) == T(1)));
467 DUNE_TEST_CHECK(bool(T(T(0)<<T(1)) == T(0)));
468 DUNE_TEST_CHECK(bool(T(T(1)<<T(1)) == T(2)));
469 }
470 template<class T>
471 void checkInfixLShift(Floating) {}
472
474
477 template<class T>
478 void checkInfixRShift(Arithmetic arithmetic_tag)
479 {
480 DUNE_TEST_FUNCTION(T, arithmetic_tag);
481
482 DUNE_TEST_CHECK(bool(T(T(0)>>T(0)) == T(0)));
483 DUNE_TEST_CHECK(bool(T(T(1)>>T(0)) == T(1)));
484 DUNE_TEST_CHECK(bool(T(T(0)>>T(1)) == T(0)));
485 DUNE_TEST_CHECK(bool(T(T(1)>>T(1)) == T(0)));
486 }
487 template<class T>
488 void checkInfixRShift(Floating) {}
489
491
494 template<class T>
495 void checkInfixLess(Arithmetic arithmetic_tag)
496 {
497 DUNE_TEST_FUNCTION(T, arithmetic_tag);
498
499 DUNE_TEST_CHECK(bool(T(0)<T(0)) == false);
500 DUNE_TEST_CHECK(bool(T(1)<T(0)) == false);
501 DUNE_TEST_CHECK(bool(T(0)<T(1)) == true );
502 DUNE_TEST_CHECK(bool(T(1)<T(1)) == false);
503 }
504 template<class T>
505 void checkInfixLess(Signed arithmetic_tag)
506 {
507 DUNE_TEST_FUNCTION(T, arithmetic_tag);
508
509 checkInfixLess<T>(Integral{});
510
511 DUNE_TEST_CHECK(bool(T(-1)<T( 0)) == true);
512 }
513 template<class T>
514 void checkInfixLess(Unsigned arithmetic_tag)
515 {
516 DUNE_TEST_FUNCTION(T, arithmetic_tag);
517
518 checkInfixLess<T>(Integral{});
519
520 DUNE_TEST_CHECK(bool(T(-1)<T( 0)) == false);
521 }
522
524
527 template<class T>
528 void checkInfixGreater(Arithmetic arithmetic_tag)
529 {
530 DUNE_TEST_FUNCTION(T, arithmetic_tag);
531
532 int values[] = { -1, 0, 1 };
533 for(int i : values)
534 for(int j : values)
535 DUNE_TEST_CHECK(bool(T(i) > T(j)) == bool(T(j) < T(i)));
536 }
537
539
542 template<class T>
543 void checkInfixLessEqual(Arithmetic arithmetic_tag)
544 {
545 DUNE_TEST_FUNCTION(T, arithmetic_tag);
546
547 int values[] = { -1, 0, 1 };
548 for(int i : values)
549 for(int j : values)
550 DUNE_TEST_CHECK(bool(T(i) <= T(j)) != bool(T(j) < T(i)));
551 }
552
554
557 template<class T>
559 {
560 DUNE_TEST_FUNCTION(T, arithmetic_tag);
561
562 int values[] = { -1, 0, 1 };
563 for(int i : values)
564 for(int j : values)
565 DUNE_TEST_CHECK(bool(T(i) >= T(j)) != bool(T(i) < T(j)));
566 }
567
569
572 template<class T>
573 void checkInfixBitAnd(Arithmetic arithmetic_tag)
574 {
575 DUNE_TEST_FUNCTION(T, arithmetic_tag);
576
577 for(int i = 0; i < 4; ++i)
578 for(int j = 0; j < 4; ++j)
579 DUNE_TEST_CHECK(bool(T(T(i) & T(j)) == T(i&j)));
580 }
581 template<class T>
582 void checkInfixBitAnd(Boolean arithmetic_tag)
583 {
584 DUNE_TEST_FUNCTION(T, arithmetic_tag);
585
586 for(int i = 0; i < 2; ++i)
587 for(int j = 0; j < 2; ++j)
588 DUNE_TEST_CHECK(bool(T(T(i) & T(j)) == T(i&j)));
589 }
590 template<class T>
591 void checkInfixBitAnd(Floating) {}
592
594
597 template<class T>
598 void checkInfixBitXor(Arithmetic arithmetic_tag)
599 {
600 DUNE_TEST_FUNCTION(T, arithmetic_tag);
601
602 for(int i = 0; i < 4; ++i)
603 for(int j = 0; j < 4; ++j)
604 DUNE_TEST_CHECK(bool(T(T(i) ^ T(j)) == T(i^j)));
605 }
606 template<class T>
607 void checkInfixBitXor(Boolean arithmetic_tag)
608 {
609 DUNE_TEST_FUNCTION(T, arithmetic_tag);
610
611 for(int i = 0; i < 2; ++i)
612 for(int j = 0; j < 2; ++j)
613 // compare the bit-flipped versions so we don't depend on the number
614 // of bits in T.
615 DUNE_TEST_CHECK(bool(T(~T(T(i) ^ T(j))) == T(~(i^j))));
616 }
617 template<class T>
618 void checkInfixBitXor(Floating) {}
619
621
624 template<class T>
625 void checkInfixBitOr(Arithmetic arithmetic_tag)
626 {
627 DUNE_TEST_FUNCTION(T, arithmetic_tag);
628
629 for(int i = 0; i < 4; ++i)
630 for(int j = 0; j < 4; ++j)
631 DUNE_TEST_CHECK(bool(T(T(i) | T(j)) == T(i|j)));
632 }
633 template<class T>
634 void checkInfixBitOr(Boolean arithmetic_tag)
635 {
636 DUNE_TEST_FUNCTION(T, arithmetic_tag);
637
638 for(int i = 0; i < 2; ++i)
639 for(int j = 0; j < 2; ++j)
640 DUNE_TEST_CHECK(bool(T(T(i) | T(j)) == T(i|j)));
641 }
642 template<class T>
643 void checkInfixBitOr(Floating) {}
644
646
649 template<class T>
650 void checkInfixAnd(Arithmetic arithmetic_tag)
651 {
652 DUNE_TEST_FUNCTION(T, arithmetic_tag);
653
654 for(int i = 0; i < 4; ++i)
655 for(int j = 0; j < 4; ++j)
656 DUNE_TEST_CHECK(bool(T(i) && T(j)) == (i && j));
657 }
658
660
663 template<class T>
664 void checkInfixOr(Arithmetic arithmetic_tag)
665 {
666 DUNE_TEST_FUNCTION(T, arithmetic_tag);
667
668 for(int i = 0; i < 4; ++i)
669 for(int j = 0; j < 4; ++j)
670 DUNE_TEST_CHECK(bool(T(i) || T(j)) == (i || j));
671 }
672
673 //
674 // checks for compound assignment operators
675 //
676
677#define DUNE_TEST_PEEL(...) __VA_ARGS__
678#define DUNE_TEST_ASSIGN(OP, name, Tag, lrange, rrange) \
679 template<class T> \
680 void checkAssign##name(Tag arithmetic_tag) \
681 { \
682 DUNE_TEST_FUNCTION(T, arithmetic_tag); \
683 \
684 for(int i : { DUNE_TEST_PEEL lrange }) \
685 for(int j : { DUNE_TEST_PEEL rrange }) \
686 { \
687 T t(i); \
688 DUNE_TEST_CHECK(bool((t OP##= T(j)) == T(T(i) OP T(j)))); \
689 DUNE_TEST_CHECK(bool(t == T(T(i) OP T(j)))); \
690 } \
691 }
692
693#define DUNE_TEST_ASSIGN_DISABLE(name, Tag) \
694 template<class T> \
695 void checkAssign##name(Tag) {}
696
697 DUNE_TEST_ASSIGN(*, Mul, Arithmetic, (0, 1, 2, 3), (0, 1, 2, 3))
698 DUNE_TEST_ASSIGN(/, Div, Arithmetic, (0, 1, 2, 3), ( 1, 2, 4))
699 DUNE_TEST_ASSIGN(%, Rem, Arithmetic, (0, 1, 2, 3), ( 1, 2, 3))
700 DUNE_TEST_ASSIGN_DISABLE(Rem, Floating)
701
702 DUNE_TEST_ASSIGN(+, Plus, Arithmetic, (0, 1, 2, 3), (0, 1, 2, 3))
703 DUNE_TEST_ASSIGN(-, Minus, Arithmetic, (0, 1, 2, 3), (0, 1, 2, 3))
704
705 DUNE_TEST_ASSIGN(<<, LShift, Integral, (0, 1, 2, 3), (0, 1, 2, 3))
706 DUNE_TEST_ASSIGN(>>, RShift, Integral, (0, 1, 2, 3), (0, 1, 2, 3))
707 DUNE_TEST_ASSIGN(<<, LShift, Boolean, (0, 1 ), (0, 1 ))
708 DUNE_TEST_ASSIGN(>>, RShift, Boolean, (0, 1 ), (0, 1 ))
709 DUNE_TEST_ASSIGN_DISABLE(LShift, Floating)
710 DUNE_TEST_ASSIGN_DISABLE(RShift, Floating)
711
712 DUNE_TEST_ASSIGN(&, BitAnd, Integral, (0, 1, 2, 3), (0, 1, 2, 3))
713 DUNE_TEST_ASSIGN(^, BitXor, Integral, (0, 1, 2, 3), (0, 1, 2, 3))
714 DUNE_TEST_ASSIGN(|, BitOr, Integral, (0, 1, 2, 3), (0, 1, 2, 3))
715 DUNE_TEST_ASSIGN_DISABLE(BitAnd, Floating)
716 DUNE_TEST_ASSIGN_DISABLE(BitXor, Floating)
717 DUNE_TEST_ASSIGN_DISABLE(BitOr, Floating)
718
719#undef DUNE_TEST_ASSIGN_DISABLE
720#undef DUNE_TEST_ASSIGN
721#undef DUNE_TEST_PEEL
722#undef DUNE_TEST_FUNCTION
723#undef DUNE_TEST_CHECK
724
725 //
726 // checks collections
727 //
728
730
745 template<class T, class Tag>
746 void checkArithmetic(Tag = Tag{})
747 {
748 auto arithmetic_tag = this->tag<Tag>();
749
750 checkDefaultConstruct<T>(arithmetic_tag);
751 checkExplicitIntConvert<T>(arithmetic_tag);
752 checkMoveConstruct<T>(arithmetic_tag);
753 checkCopyConstruct<T>(arithmetic_tag);
754 checkMoveAssign<T>(arithmetic_tag);
755 checkCopyAssign<T>(arithmetic_tag);
756 checkEqual<T>(arithmetic_tag);
757
758 checkPostfixInc<T>(arithmetic_tag);
759 checkPostfixDec<T>(arithmetic_tag);
760
761 checkPrefixPlus<T>(arithmetic_tag);
762 checkPrefixMinus<T>(arithmetic_tag);
763 checkPrefixNot<T>(arithmetic_tag);
764 checkPrefixBitNot<T>(arithmetic_tag);
765
766 checkPrefixInc<T>(arithmetic_tag);
767 checkPrefixDec<T>(arithmetic_tag);
768
769 checkInfixMul<T>(arithmetic_tag);
770 checkInfixDiv<T>(arithmetic_tag);
771 checkInfixRem<T>(arithmetic_tag);
772
773 checkInfixPlus<T>(arithmetic_tag);
774 checkInfixMinus<T>(arithmetic_tag);
775
776 checkInfixLShift<T>(arithmetic_tag);
777 checkInfixRShift<T>(arithmetic_tag);
778
779 checkInfixLess<T>(arithmetic_tag);
780 checkInfixGreater<T>(arithmetic_tag);
781 checkInfixLessEqual<T>(arithmetic_tag);
782 checkInfixGreaterEqual<T>(arithmetic_tag);
783
784 checkInfixBitAnd<T>(arithmetic_tag);
785 checkInfixBitXor<T>(arithmetic_tag);
786 checkInfixBitOr<T>(arithmetic_tag);
787
788 checkInfixAnd<T>(arithmetic_tag);
789 checkInfixOr<T>(arithmetic_tag);
790
791 checkAssignMul<T>(arithmetic_tag);
792 checkAssignDiv<T>(arithmetic_tag);
793 checkAssignRem<T>(arithmetic_tag);
794
795 checkAssignPlus<T>(arithmetic_tag);
796 checkAssignMinus<T>(arithmetic_tag);
797
798 checkAssignLShift<T>(arithmetic_tag);
799 checkAssignRShift<T>(arithmetic_tag);
800
801 checkAssignBitAnd<T>(arithmetic_tag);
802 checkAssignBitXor<T>(arithmetic_tag);
803 checkAssignBitOr<T>(arithmetic_tag);
804 }
805 };
806
807#ifdef CLANG_WARNING_DISABLED
808# pragma clang diagnostic pop
809# undef CLANG_WARNING_DISABLED
810#endif
811
812#ifdef GCC_WARNING_DISABLED
813# pragma GCC diagnostic pop
814# undef GCC_WARNING_DISABLED
815#endif
816
817} // namespace Dune
818
819#endif // DUNE_COMMON_TEST_ARITHMETICTESTSUITE_HH
Test suite for arithmetic types.
Definition: arithmetictestsuite.hh:45
void checkPrefixBitNot(Boolean arithmetic_tag)
check prefix ~
Definition: arithmetictestsuite.hh:312
void checkCopyAssign(Arithmetic arithmetic_tag)
check the copy assignment operator
Definition: arithmetictestsuite.hh:188
void checkPrefixPlus(Arithmetic arithmetic_tag)
check prefix +
Definition: arithmetictestsuite.hh:273
void checkInfixAnd(Arithmetic arithmetic_tag)
check infix &&
Definition: arithmetictestsuite.hh:650
void checkMoveConstruct(Arithmetic arithmetic_tag)
check the move constructor
Definition: arithmetictestsuite.hh:131
void checkInfixRShift(Arithmetic arithmetic_tag)
check infix >>
Definition: arithmetictestsuite.hh:478
void checkInfixLessEqual(Arithmetic arithmetic_tag)
check infix <=
Definition: arithmetictestsuite.hh:543
void checkInfixBitOr(Arithmetic arithmetic_tag)
check infix |
Definition: arithmetictestsuite.hh:625
void checkMoveAssign(Arithmetic arithmetic_tag)
check the move assignment operator
Definition: arithmetictestsuite.hh:171
void checkInfixGreater(Arithmetic arithmetic_tag)
check infix >
Definition: arithmetictestsuite.hh:528
void checkPrefixMinus(Arithmetic arithmetic_tag)
check prefix -
Definition: arithmetictestsuite.hh:286
void checkInfixLShift(Arithmetic arithmetic_tag)
check infix <<
Definition: arithmetictestsuite.hh:461
void checkInfixPlus(Arithmetic arithmetic_tag)
check infix +
Definition: arithmetictestsuite.hh:431
void checkPrefixInc(Arithmetic arithmetic_tag)
check postfix ++
Definition: arithmetictestsuite.hh:347
void checkInfixBitAnd(Arithmetic arithmetic_tag)
check infix &
Definition: arithmetictestsuite.hh:573
void checkPrefixDec(Arithmetic arithmetic_tag)
check postfix --
Definition: arithmetictestsuite.hh:365
void checkInfixDiv(Arithmetic arithmetic_tag)
check infix /
Definition: arithmetictestsuite.hh:403
void checkInfixBitXor(Arithmetic arithmetic_tag)
check infix ^
Definition: arithmetictestsuite.hh:598
void checkPrefixNot(Arithmetic arithmetic_tag)
check prefix !
Definition: arithmetictestsuite.hh:299
void checkInfixGreaterEqual(Arithmetic arithmetic_tag)
check infix >=
Definition: arithmetictestsuite.hh:558
void checkDefaultConstruct(Arithmetic arithmetic_tag)
check the default constructors
Definition: arithmetictestsuite.hh:110
void checkPostfixDec(Arithmetic arithmetic_tag)
check postfix --
Definition: arithmetictestsuite.hh:257
void checkExplicitIntConvert(Arithmetic arithmetic_tag)
check explicit conversion from and to int
Definition: arithmetictestsuite.hh:120
void checkEqual(Arithmetic arithmetic_tag)
check == and !=
Definition: arithmetictestsuite.hh:211
void checkInfixMinus(Arithmetic arithmetic_tag)
check infix -
Definition: arithmetictestsuite.hh:446
void checkPostfixInc(Arithmetic arithmetic_tag)
check postfix ++
Definition: arithmetictestsuite.hh:241
void checkInfixRem(Arithmetic arithmetic_tag)
check infix %
Definition: arithmetictestsuite.hh:416
void checkInfixOr(Arithmetic arithmetic_tag)
check infix ||
Definition: arithmetictestsuite.hh:664
void checkInfixMul(Arithmetic arithmetic_tag)
check infix *
Definition: arithmetictestsuite.hh:388
void checkCopyConstruct(Arithmetic arithmetic_tag)
check the copy constructor
Definition: arithmetictestsuite.hh:149
void checkInfixLess(Arithmetic arithmetic_tag)
check infix <
Definition: arithmetictestsuite.hh:495
static constexpr auto tag(T=T{})
determine arithmetic tag for the given type
Definition: arithmetictestsuite.hh:83
A Simple helper class to organize your test suite.
Definition: testsuite.hh:31
std::string name() const
Query name.
Definition: testsuite.hh:238
TestSuite(ThrowPolicy policy, std::string name="")
Create TestSuite.
Definition: testsuite.hh:45
A free function to provide the demangled class name of a given object or type as a string.
Dune namespace.
Definition: alignedallocator.hh:13
tag denoting any arithmetic type
Definition: arithmetictestsuite.hh:51
tag denoting boolean types
Definition: arithmetictestsuite.hh:55
tag denoting floating point types
Definition: arithmetictestsuite.hh:61
tag denoting integral types
Definition: arithmetictestsuite.hh:53
tag denoting signed integral types
Definition: arithmetictestsuite.hh:57
tag denoting unsigned integral types
Definition: arithmetictestsuite.hh:59
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)