1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 | // *****************************************************************************
/*!
\file tests/unit/Base/TestHas.cpp
\copyright 2012-2015 J. Bakosi,
2016-2018 Los Alamos National Security, LLC.,
2019-2021 Triad National Security, LLC.,
2022-2025 J. Bakosi
All rights reserved. See the LICENSE file for details.
\brief Unit tests for Base/Has.hpp
\details Unit tests for Base/Has.hpp
*/
// *****************************************************************************
#include <unistd.h><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include "NoWarning/tut.hpp"<--- Include file: "NoWarning/tut.hpp" not found.
#include "TUTConfig.hpp"<--- Include file: "TUTConfig.hpp" not found.
#include "Has.hpp"
#ifndef DOXYGEN_GENERATING_OUTPUT
namespace tut {
//! All tests in group inherited from this base
struct Has_common {
struct noAlias {};
struct yesAlias { using alias = char; };
struct noCode {};
struct yesCode { using code = char; };
struct noExpectDescription {};
struct yesExpectDescription { struct expect{ void description(){} }; };
struct noExpectLower {};
struct yesExpectLower { struct expect{ int lower = 1; }; };
struct noExpectUpper {};
struct yesExpectUpper { struct expect{ int upper = 1; }; };
struct noExpectChoices {};
struct yesExpectChoices { struct expect{ void choices(){} }; };
};
//! Test group shortcuts
using Has_group = test_group< Has_common, MAX_TESTS_IN_GROUP >;
using Has_object = Has_group::object;
//! Define test group
static Has_group Has( "Base/Has" );
//! Test definitions for group
//! Test if tk::HasTypedef_alias correctly detects the absence of typedef alias
template<> template<>
void Has_object::test< 1 >() {
set_test_name( "HasTypedef_alias detects absence" );
struct no { bool value = tk::HasTypedef_alias_v< noAlias >; };
ensure_equals( "struct has no alias", no().value, false );
}
//! Test if tk::HasTypedef_alias correctly detects the presence of typedef alias
template<> template<>
void Has_object::test< 2 >() {
set_test_name( "HasTypedef_alias detects presence" );
struct yes { bool value = tk::HasTypedef_alias_v< yesAlias >; };
ensure_equals( "struct has alias", yes().value, true );
}
//! Test if tk::HasTypedef_code correctly detects the absence of typedef code
template<> template<>
void Has_object::test< 3 >() {
set_test_name( "HasTypedef_code detects absence" );
struct no { bool value = tk::HasTypedef_code_v< noCode >; };
ensure_equals( "struct has no code", no().value, false );
}
//! Test if tk::HasTypedef_code correctly detects the presence of typedef code
template<> template<>
void Has_object::test< 4 >() {
set_test_name( "HasTypedef_code detects presence" );
struct yes { bool value = tk::HasTypedef_code_v< yesCode >; };
ensure_equals( "struct has code", yes().value, true );
}
//! \brief Test if tk::HasFunction_expect_description correctly detects the
//! absence of function expect::description()
template<> template<>
void Has_object::test< 5 >() {
set_test_name( "HasFunction_expect_description: absence" );
struct no {
bool value = tk::HasFunction_expect_description_v< noExpectDescription >;
};
ensure_equals( "struct has no expect::description", no().value, false );
}
//! \brief Test if tk::HasFunction_expect_description correctly detects the
//! presence of function expect::description()
template<> template<>
void Has_object::test< 6 >() {
set_test_name( "HasFunction_expect_description: presence" );
struct yes {
bool value = tk::HasFunction_expect_description_v< yesExpectDescription >;
};
ensure_equals( "struct has expect::description", yes().value, true );
}
//! \brief Test if tk::HasVar_expect_lower correctly detects the
//! absence of function expect::lower()
template<> template<>
void Has_object::test< 7 >() {
set_test_name( "HasVar_expect_lower: absence" );
struct no {
bool value = tk::HasVar_expect_lower_v< noExpectLower >;
};
ensure_equals( "struct has no expect::lower", no().value, false );
}
//! \brief Test if tk::HasVar_expect_lower correctly detects the
//! presence of variable expect::lower()
template<> template<>
void Has_object::test< 8 >() {
set_test_name( "HasVar_expect_lower: presence" );
struct yes {
bool value = tk::HasVar_expect_lower_v< yesExpectLower >;
};
ensure_equals( "struct has expect::lower", yes().value, true );
}
//! \brief Test if tk::HasVar_expect_upper correctly detects the
//! absence of function expect::upper()
template<> template<>
void Has_object::test< 9 >() {
set_test_name( "HasVar_expect_upper: absence" );
struct no {
bool value = tk::HasVar_expect_upper_v< noExpectUpper >;
};
ensure_equals( "struct has no expect::upper", no().value, false );
}
//! \brief Test if tk::HasVar_expect_upper correctly detects the
//! presence of variable expect::upper()
template<> template<>
void Has_object::test< 10 >() {
set_test_name( "HasVar_expect_upper: presence" );
struct yes {
bool value = tk::HasVar_expect_upper_v< yesExpectUpper >;
};
ensure_equals( "struct has expect::upper", yes().value, true );
}
//! \brief Test if tk::HasFunction_expect_choices correctly detects the absence
//! of function expect::choices()
template<> template<>
void Has_object::test< 11 >() {
set_test_name( "HasFunction_expect_choices: absence" );
struct no {
bool value = tk::HasFunction_expect_choices_v< noExpectChoices >;
};
ensure_equals( "struct has no expect::choices", no().value, false );
}
//! \brief Test if tk::HasFunction_expect_choices correctly detects the presence
//! of function expect::choices()
template<> template<>
void Has_object::test< 12 >() {
set_test_name( "HasFunction_expect_choices: presence" );
struct yes {
bool value = tk::HasFunction_expect_choices_v< yesExpectChoices >;
};
ensure_equals( "struct has expect::choices", yes().value, true );
}
} // tut::
#endif // DOXYGEN_GENERATING_OUTPUT
|