-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathspan-main.t.cpp
237 lines (207 loc) · 6.89 KB
/
span-main.t.cpp
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Copyright 2018-2019 Martin Moene
//
// https://github.com/martinmoene/span-lite
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "span-main.t.hpp"
#ifndef span_HAVE
# define span_HAVE( feature ) ( span_HAVE_##feature )
#endif
#define span_PRESENT( x ) \
std::cout << #x << ": " << x << "\n"
#define span_ABSENT( x ) \
std::cout << #x << ": (undefined)\n"
lest::tests & specification()
{
static lest::tests tests;
return tests;
}
CASE( "span-lite version" "[.span][.version]" )
{
span_PRESENT( span_lite_MAJOR );
span_PRESENT( span_lite_MINOR );
span_PRESENT( span_lite_PATCH );
span_PRESENT( span_lite_VERSION );
}
CASE( "span configuration" "[.span][.config]" )
{
#if span_USES_STD_SPAN
std::cout << "(Note: Configuration has no effect: using std::span)\n";
#endif
span_PRESENT( span_HAVE_STD_SPAN );
span_PRESENT( span_USES_STD_SPAN );
span_PRESENT( span_SPAN_DEFAULT );
span_PRESENT( span_SPAN_NONSTD );
span_PRESENT( span_SPAN_STD );
span_PRESENT( span_CONFIG_SELECT_SPAN );
// span_PRESENT( span_CONFIG_EXTENT_TYPE );
// span_PRESENT( span_CONFIG_SIZE_TYPE );
span_PRESENT( span_CONFIG_NO_EXCEPTIONS );
}
CASE( "Presence of span library features" "[.span][.config]" )
{
#if span_USES_STD_SPAN
std::cout << "(Note: library feature configuration has no effect: using std::span)\n";
#endif
span_PRESENT( span_FEATURE_BYTE_SPAN );
span_PRESENT( span_FEATURE_MAKE_SPAN );
#ifdef span_FEATURE_MAKE_SPAN_TO_STD
span_PRESENT( span_FEATURE_MAKE_SPAN_TO_STD );
#else
span_ABSENT( span_FEATURE_MAKE_SPAN_TO_STD );
#endif
span_PRESENT( span_FEATURE_WITH_CONTAINER );
#ifdef span_FEATURE_WITH_CONTAINER_TO_STD
span_PRESENT( span_FEATURE_WITH_CONTAINER_TO_STD );
#else
span_ABSENT( span_FEATURE_WITH_CONTAINER_TO_STD );
#endif
span_PRESENT( span_FEATURE_CONSTRUCTION_FROM_STDARRAY_ELEMENT_TYPE );
span_PRESENT( span_FEATURE_MEMBER_CALL_OPERATOR );
span_PRESENT( span_FEATURE_MEMBER_AT );
span_PRESENT( span_FEATURE_MEMBER_BACK_FRONT );
span_PRESENT( span_FEATURE_MEMBER_SWAP );
span_PRESENT( span_FEATURE_NON_MEMBER_FIRST_LAST_SUB );
span_PRESENT( span_FEATURE_COMPARISON );
span_PRESENT( span_FEATURE_SAME );
}
CASE( "span configuration, contract level" "[.span][.config][.contract]" )
{
#if span_USES_STD_SPAN
std::cout << "(Note: contract level configuration has no effect: using std::span)\n";
#endif
#ifdef span_CONFIG_CONTRACT_LEVEL_ON
span_PRESENT( span_CONFIG_CONTRACT_LEVEL_ON );
#else
span_ABSENT( span_CONFIG_CONTRACT_LEVEL_ON );
#endif
#ifdef span_CONFIG_CONTRACT_LEVEL_OFF
span_PRESENT( span_CONFIG_CONTRACT_LEVEL_OFF );
#else
span_ABSENT( span_CONFIG_CONTRACT_LEVEL_OFF );
#endif
#ifdef span_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY
span_PRESENT( span_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY );
#else
span_ABSENT( span_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY );
#endif
#ifdef span_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY
span_PRESENT( span_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY );
#else
span_ABSENT( span_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY );
#endif
#ifdef span_CONFIG_CONTRACT_VIOLATION_THROWS
span_PRESENT( span_CONFIG_CONTRACT_VIOLATION_THROWS );
#else
span_ABSENT( span_CONFIG_CONTRACT_VIOLATION_THROWS );
#endif
#ifdef span_CONFIG_CONTRACT_VIOLATION_TERMINATES
span_PRESENT( span_CONFIG_CONTRACT_VIOLATION_TERMINATES );
#else
span_ABSENT( span_CONFIG_CONTRACT_VIOLATION_TERMINATES );
#endif
}
CASE( "__cplusplus" "[.stdc++]" )
{
span_PRESENT( __cplusplus );
#ifdef _MSVC_LANG
span_PRESENT( _MSVC_LANG );
#else
span_ABSENT( _MSVC_LANG );
#endif
span_PRESENT( span_CPLUSPLUS );
span_PRESENT( span_CPLUSPLUS_V );
}
CASE( "Compiler version" "[.compiler]" )
{
#if span_USES_STD_SPAN
std::cout << "(Compiler version not available: using std::span)\n";
#else
span_PRESENT( span_COMPILER_CLANG_VERSION );
span_PRESENT( span_COMPILER_GNUC_VERSION );
span_PRESENT( span_COMPILER_MSVC_VERSION );
#endif
}
CASE( "Presence of C++ language features" "[.stdlanguage]" )
{
#if defined(__cpp_exceptions)
span_PRESENT( __cpp_exceptions );
#else
span_ABSENT( __cpp_exceptions );
#endif
#if defined(__EXCEPTIONS)
span_PRESENT( __EXCEPTIONS );
#else
span_ABSENT( __EXCEPTIONS );
#endif
#if defined(_CPPUNWIND)
span_PRESENT( _CPPUNWIND );
#else
span_ABSENT( _CPPUNWIND );
#endif
#if defined(_DEBUG)
span_PRESENT( _DEBUG );
#else
span_ABSENT( _DEBUG );
#endif
#if defined(NDEBUG)
span_PRESENT( NDEBUG );
#else
span_ABSENT( NDEBUG );
#endif
#if span_USES_STD_SPAN
std::cout << "(Presence of C++ language features not available: using std::span)\n";
#else
span_PRESENT( span_HAVE_ALIAS_TEMPLATE );
span_PRESENT( span_HAVE_AUTO );
span_PRESENT( span_HAVE_CONSTEXPR_11 );
span_PRESENT( span_HAVE_CONSTEXPR_14 );
span_PRESENT( span_HAVE_CONSTRAINED_SPAN_CONTAINER_CTOR );
span_PRESENT( span_HAVE_DEDUCTION_GUIDES );
span_PRESENT( span_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG );
span_PRESENT( span_HAVE_DEPRECATED );
span_PRESENT( span_HAVE_EXPLICIT_CONVERSION );
span_PRESENT( span_HAVE_IS_DEFAULT );
span_PRESENT( span_HAVE_IS_DELETE );
span_PRESENT( span_HAVE_NODISCARD );
span_PRESENT( span_HAVE_NOEXCEPT );
span_PRESENT( span_HAVE_NORETURN );
span_PRESENT( span_HAVE_NULLPTR );
span_PRESENT( span_HAVE_STATIC_ASSERT );
#endif
}
CASE( "Presence of C++ library features" "[.stdlibrary]" )
{
#if span_USES_STD_SPAN
std::cout << "(Presence of C++ library features not available: using std::span)\n";
#else
span_PRESENT( span_HAS_CPP0X );
span_PRESENT( span_HAVE_ADDRESSOF );
span_PRESENT( span_HAVE_ARRAY );
span_PRESENT( span_HAVE_BYTE );
span_PRESENT( span_HAVE_CONDITIONAL );
span_PRESENT( span_HAVE_CONTAINER_DATA_METHOD );
span_PRESENT( span_HAVE_DATA );
span_PRESENT( span_HAVE_NONSTD_BYTE );
span_PRESENT( span_HAVE_REMOVE_CONST );
span_PRESENT( span_HAVE_SNPRINTF );
span_PRESENT( span_HAVE_STRUCT_BINDING );
span_PRESENT( span_HAVE_TYPE_TRAITS );
#endif
}
int main( int argc, char * argv[] )
{
return lest::run( specification(), argc, argv );
}
#if 0
g++ -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++98 -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++03 -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++0x -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++11 -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++14 -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
g++ -std=c++17 -I../include -o span-lite.t.exe span-lite.t.cpp && span-lite.t.exe --pass
cl -EHsc -I../include span-lite.t.cpp && span-lite.t.exe --pass
#endif
// end of file