|
1 | 1 | #pragma once
|
2 | 2 | #include "Compare.h"
|
3 | 3 |
|
4 |
| -// helper define for the operators below |
5 |
| -#define assertOp(desc, relevance1, arg1, op, op_name, relevance2, arg2) \ |
6 |
| - do \ |
7 |
| - { \ |
8 |
| - if (!assertion<typeof(arg1), typeof(arg2)>(__FILE__, __LINE__, \ |
9 |
| - desc, \ |
10 |
| - relevance1, #arg1, (arg1), \ |
11 |
| - op_name, op, \ |
12 |
| - relevance2, #arg2, (arg2))) \ |
13 |
| - { \ |
14 |
| - return; \ |
15 |
| - } \ |
| 4 | +#define testBehaviorOp(die, desc, rel1, arg1, op, op_name, rel2, arg2) \ |
| 5 | + do \ |
| 6 | + { \ |
| 7 | + if (!assertion<typeof(arg1), typeof(arg2)>(__FILE__, __LINE__, \ |
| 8 | + desc, \ |
| 9 | + rel1, #arg1, (arg1), \ |
| 10 | + op_name, op, \ |
| 11 | + rel2, #arg2, (arg2))) \ |
| 12 | + { \ |
| 13 | + if (die) return; \ |
| 14 | + } \ |
16 | 15 | } while (0)
|
17 | 16 |
|
18 |
| -/** macro generates optional output and calls fail() followed by a return if false. */ |
| 17 | + |
| 18 | + |
| 19 | +// helper define for the operators below |
| 20 | +#define assertOp(desc, rel1, arg1, op, op_name, rel2, arg2) \ |
| 21 | + testBehaviorOp(false, desc, rel1, arg1, op, op_name, rel2, arg2) |
| 22 | + |
| 23 | +#define assureOp(desc, rel1, arg1, op, op_name, rel2, arg2) \ |
| 24 | + testBehaviorOp(true, desc, rel1, arg1, op, op_name, rel2, arg2) |
| 25 | + |
| 26 | + |
| 27 | +/** macro generates optional output and calls fail() but does not return if false. */ |
19 | 28 | #define assertEqual(arg1,arg2) assertOp("assertEqual","expected",arg1,compareEqual,"==","actual",arg2)
|
20 | 29 | #define assertNotEqual(arg1,arg2) assertOp("assertNotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2)
|
21 | 30 | #define assertLess(arg1,arg2) assertOp("assertLess","lowerBound",arg1,compareLess,"<","upperBound",arg2)
|
|
25 | 34 | #define assertTrue(arg) assertEqual(arg,true)
|
26 | 35 | #define assertFalse(arg) assertEqual(arg,false)
|
27 | 36 |
|
| 37 | +/** macro generates optional output and calls fail() followed by a return if false. */ |
| 38 | +#define assureEqual(arg1,arg2) assureOp("assureEqual","expected",arg1,compareEqual,"==","actual",arg2) |
| 39 | +#define assureNotEqual(arg1,arg2) assureOp("assureNotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2) |
| 40 | +#define assureLess(arg1,arg2) assureOp("assureLess","lowerBound",arg1,compareLess,"<","upperBound",arg2) |
| 41 | +#define assureMore(arg1,arg2) assureOp("assureMore","upperBound",arg1,compareMore,">","lowerBound",arg2) |
| 42 | +#define assureLessOrEqual(arg1,arg2) assureOp("assureLessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","upperBound",arg2) |
| 43 | +#define assureMoreOrEqual(arg1,arg2) assureOp("assureMoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","lowerBound",arg2) |
| 44 | +#define assureTrue(arg) assertEqual(arg,true) |
| 45 | +#define assureFalse(arg) assertEqual(arg,false) |
| 46 | + |
0 commit comments