cpprisc16  March 16, 2017
 All Namespaces Files Functions Variables Typedefs Macros
assert.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 
3 /** \file cpprisc16/assert.hpp (March 12, 2017)
4  * \brief Helper assertions.
5  *
6  * Piece of cpprisc16.
7  * https://bitbucket.org/OPiMedia/cpprisc16
8  *
9  * GPLv3 --- Copyright (C) 2017 Olivier Pirson
10  * http://www.opimedia.be/
11  */
12 
13 #ifndef CPPRISC16_CPPRISC16_ASSERT_HPP_
14 #define CPPRISC16_CPPRISC16_ASSERT_HPP_
15 
16 #include <cstdint>
17 
18 
19 /* ********
20  * Macros *
21  **********/
22 
23 /** \brief
24  * Check if a, b and c are different
25  */
26 #define ASSERT_3_DIFFERENT(a, b, c) { \
27  assert(a != b); \
28  assert(a != c); \
29  \
30  assert(b != c); \
31  }
32 
33 
34 /** \brief
35  * Check if a, b, c and d are different
36  */
37 #define ASSERT_4_DIFFERENT(a, b, c, d) { \
38  assert(a != b); \
39  assert(a != c); \
40  assert(a != d); \
41  \
42  assert(b != c); \
43  assert(b != d); \
44  \
45  assert(c != d); \
46  }
47 
48 
49 /** \brief
50  * Check if a, b, c, d and e are different
51  */
52 #define ASSERT_5_DIFFERENT(a, b, c, d, e) { \
53  assert(a != b); \
54  assert(a != c); \
55  assert(a != d); \
56  assert(a != e); \
57  \
58  assert(b != c); \
59  assert(b != d); \
60  assert(b != e); \
61  \
62  assert(c != d); \
63  assert(c != e); \
64  \
65  assert(d != e); \
66  }
67 
68 
69 /** \brief
70  * Check if a, b, c, d, e and f are different
71  */
72 #define ASSERT_6_DIFFERENT(a, b, c, d, e, f) { \
73  assert(a != b); \
74  assert(a != c); \
75  assert(a != d); \
76  assert(a != e); \
77  assert(a != f); \
78  \
79  assert(b != c); \
80  assert(b != d); \
81  assert(b != e); \
82  assert(b != f); \
83  \
84  assert(c != d); \
85  assert(c != e); \
86  assert(c != f); \
87  \
88  assert(d != e); \
89  assert(d != f); \
90  \
91  assert(e != f); \
92  }
93 
94 
95 /** \brief
96  * Check if a, b, c, d, e, f and g are different
97  */
98 #define ASSERT_7_DIFFERENT(a, b, c, d, e, f, g) { \
99  assert(a != b); \
100  assert(a != c); \
101  assert(a != d); \
102  assert(a != e); \
103  assert(a != f); \
104  assert(a != g); \
105  \
106  assert(b != c); \
107  assert(b != d); \
108  assert(b != e); \
109  assert(b != f); \
110  assert(b != g); \
111  \
112  assert(c != d); \
113  assert(c != e); \
114  assert(c != f); \
115  assert(c != g); \
116  \
117  assert(d != e); \
118  assert(d != f); \
119  assert(d != g); \
120  \
121  assert(e != f); \
122  assert(e != g); \
123  \
124  assert(f != g); \
125  }
126 
127 #endif // CPPRISC16_CPPRISC16_ASSERT_HPP_