• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #856

28 Dec 2022 02:00AM UTC coverage: 86.602% (+0.05%) from 86.55%
#856

push

StellarBot
Merge #6119

6119: Update CMakeLists.txt r=hkaiser a=khuck

updating the default APEX version


Co-authored-by: Kevin Huck <khuck@cs.uoregon.edu>

174566 of 201573 relevant lines covered (86.6%)

1876093.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.75
/libs/core/testing/include/hpx/modules/testing.hpp
1
////////////////////////////////////////////////////////////////////////////////
2
//  Copyright (c) 2011 Bryce Lelbach
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
////////////////////////////////////////////////////////////////////////////////
8

9
#pragma once
10

11
#include <hpx/config.hpp>
12
#include <hpx/assert.hpp>
13
#include <hpx/functional/function.hpp>
14
#include <hpx/preprocessor/cat.hpp>
15
#include <hpx/preprocessor/expand.hpp>
16
#include <hpx/preprocessor/nargs.hpp>
17
#include <hpx/preprocessor/stringize.hpp>
18
#include <hpx/testing/performance.hpp>
19
#include <hpx/thread_support/spinlock.hpp>
20
#include <hpx/util/ios_flags_saver.hpp>
21

22
#include <cstddef>
23
#include <cstdint>
24
#include <mutex>
25
#include <ostream>
26

27
namespace hpx::util {
28

29
    using test_failure_handler_type = hpx::function<void()>;
30

31
    HPX_CORE_EXPORT void set_test_failure_handler(test_failure_handler_type f);
32

33
    enum class counter_type
34
    {
35
        sanity,
36
        test
37
    };
38

39
    namespace detail {
40

41
        struct fixture
42
        {
43
        public:
44
            using mutex_type = hpx::util::detail::spinlock;
45

46
        private:
47
            std::ostream& stream_;
48
            mutex_type mutex_;
49

50
        public:
51
            explicit fixture(std::ostream& stream) noexcept
973✔
52
              : stream_(stream)
973✔
53
            {
54
            }
973✔
55

56
            HPX_CORE_EXPORT void increment(counter_type c) noexcept;
57

58
            HPX_CORE_EXPORT std::size_t get(counter_type c) const noexcept;
59

60
            template <typename T>
61
            bool check_(char const* file, int line, char const* function,
41,085,775✔
62
                counter_type c, T const& t, char const* msg)
63
            {
64
                if (!t)
41,087,843✔
65
                {
66
                    std::lock_guard<mutex_type> l(mutex_);
13✔
67
                    hpx::util::ios_flags_saver ifs(stream_);
13✔
68
                    stream_ << file << "(" << line << "): " << msg
13✔
69
                            << " failed in function '" << function << "'"
13✔
70
                            << std::endl;
13✔
71
                    increment(c);
13✔
72
                    return false;
13✔
73
                }
13✔
74
                return true;
41,085,776✔
75
            }
41,085,789✔
76

77
            template <typename T, typename U>
78
            bool check_equal(char const* file, int line, char const* function,
17,635,145✔
79
                counter_type c, T const& t, U const& u, char const* msg)
80
            {
81
                if (!(t == u))
17,645,345✔
82
                {
83
                    std::lock_guard<mutex_type> l(mutex_);
193✔
84
                    hpx::util::ios_flags_saver ifs(stream_);
193✔
85
                    stream_ << file << "(" << line << "): " << msg
193✔
86
                            << " failed in function '" << function << "': "
193✔
87
                            << "'" << t << "' != '" << u << "'" << std::endl;
193✔
88
                    increment(c);
193✔
89
                    return false;
193✔
90
                }
193✔
91
                return true;
17,641,506✔
92
            }
17,641,699✔
93

94
            template <typename T, typename U>
95
            bool check_not_equal(char const* file, int line,
785,633✔
96
                char const* function, counter_type c, T const& t, U const& u,
97
                char const* msg)
98
            {
99
                if (!(t != u))
785,638✔
100
                {
101
                    std::lock_guard<mutex_type> l(mutex_);
720✔
102
                    hpx::util::ios_flags_saver ifs(stream_);
720✔
103
                    stream_ << file << "(" << line << "): " << msg
720✔
104
                            << " failed in function '" << function << "': "
720✔
105
                            << "'" << t << "' != '" << u << "'" << std::endl;
720✔
106
                    increment(c);
720✔
107
                    return false;
720✔
108
                }
720✔
109
                return true;
784,918✔
110
            }
785,638✔
111

112
            template <typename T, typename U>
113
            bool check_less(char const* file, int line, char const* function,
390✔
114
                counter_type c, T const& t, U const& u, char const* msg)
115
            {
116
                if (!(t < u))
390✔
117
                {
118
                    std::lock_guard<mutex_type> l(mutex_);
×
119
                    hpx::util::ios_flags_saver ifs(stream_);
×
120
                    stream_ << file << "(" << line << "): " << msg
×
121
                            << " failed in function '" << function << "': "
×
122
                            << "'" << t << "' >= '" << u << "'" << std::endl;
×
123
                    increment(c);
×
124
                    return false;
×
125
                }
×
126
                return true;
390✔
127
            }
390✔
128

129
            template <typename T, typename U>
130
            bool check_less_equal(char const* file, int line,
1,586✔
131
                char const* function, counter_type c, T const& t, U const& u,
132
                char const* msg)
133
            {
134
                if (!(t <= u))
1,586✔
135
                {
136
                    std::lock_guard<mutex_type> l(mutex_);
×
137
                    hpx::util::ios_flags_saver ifs(stream_);
×
138
                    stream_ << file << "(" << line << "): " << msg
×
139
                            << " failed in function '" << function << "': "
×
140
                            << "'" << t << "' > '" << u << "'" << std::endl;
×
141
                    increment(c);
×
142
                    return false;
×
143
                }
×
144
                return true;
1,586✔
145
            }
1,586✔
146

147
            template <typename T, typename U, typename V>
148
            bool check_range(char const* file, int line, char const* function,
3,289✔
149
                counter_type c, T const& t, U const& u, V const& v,
150
                char const* msg)
151
            {
152
                if (!(t >= u && t <= v))
3,289✔
153
                {
154
                    std::lock_guard<mutex_type> l(mutex_);
×
155
                    hpx::util::ios_flags_saver ifs(stream_);
×
156
                    if (!(t >= u))
×
157
                    {
158
                        stream_ << file << "(" << line << "): " << msg
×
159
                                << " failed in function '" << function << "': "
×
160
                                << "'" << t << "' < '" << u << "'" << std::endl;
×
161
                    }
×
162
                    else
163
                    {
164
                        stream_ << file << "(" << line << "): " << msg
×
165
                                << " failed in function '" << function << "': "
×
166
                                << "'" << t << "' > '" << v << "'" << std::endl;
×
167
                    }
168
                    increment(c);
×
169
                    return false;
×
170
                }
×
171
                return true;
3,289✔
172
            }
3,289✔
173
        };
174

175
        HPX_CORE_EXPORT fixture& global_fixture() noexcept;
176

177
    }    // namespace detail
178

179
    ////////////////////////////////////////////////////////////////////////////
180
    HPX_CORE_EXPORT int report_errors();
181
    HPX_CORE_EXPORT int report_errors(std::ostream& stream);
182
    HPX_CORE_EXPORT void print_cdash_timing(char const* name, double time);
183
    HPX_CORE_EXPORT void print_cdash_timing(
184
        char const* name, std::uint64_t time);
185
}    // namespace hpx::util
186

187
////////////////////////////////////////////////////////////////////////////////
188
#define HPX_TEST(...)                                                          \
189
    HPX_TEST_(__VA_ARGS__)                                                     \
190
    /**/
191

192
#define HPX_TEST_(...)                                                         \
193
    HPX_PP_EXPAND(                                                             \
194
        HPX_PP_CAT(HPX_TEST_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))         \
195
    /**/
196
#define HPX_TEST_1(expr)                                                       \
197
    HPX_TEST_IMPL(::hpx::util::detail::global_fixture(), expr)
198
#define HPX_TEST_2(strm, expr)                                                 \
199
    HPX_TEST_IMPL(::hpx::util::detail::fixture{strm}, expr)
200

201
#define HPX_TEST_IMPL(fixture, expr)                                           \
202
    fixture.check_(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,            \
203
        ::hpx::util::counter_type::test, expr,                                 \
204
        "test '" HPX_PP_STRINGIZE(expr) "'")
205

206
////////////////////////////////////////////////////////////////////////////////
207
#define HPX_TEST_MSG(...)                                                      \
208
    HPX_TEST_MSG_(__VA_ARGS__)                                                 \
209
    /**/
210

211
#define HPX_TEST_MSG_(...)                                                     \
212
    HPX_PP_EXPAND(                                                             \
213
        HPX_PP_CAT(HPX_TEST_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))     \
214
    /**/
215
#define HPX_TEST_MSG_2(expr, msg)                                              \
216
    HPX_TEST_MSG_IMPL(::hpx::util::detail::global_fixture(), expr, msg)
217
#define HPX_TEST_MSG_3(strm, expr, msg)                                        \
218
    HPX_TEST_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr, msg)
219

220
#define HPX_TEST_MSG_IMPL(fixture, expr, msg)                                  \
221
    fixture.check_(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,            \
222
        ::hpx::util::counter_type::test, expr, msg)
223

224
////////////////////////////////////////////////////////////////////////////////
225
#define HPX_TEST_EQ(...)                                                       \
226
    HPX_TEST_EQ_(__VA_ARGS__)                                                  \
227
    /**/
228

229
#define HPX_TEST_EQ_(...)                                                      \
230
    HPX_PP_EXPAND(                                                             \
231
        HPX_PP_CAT(HPX_TEST_EQ_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))      \
232
    /**/
233
#define HPX_TEST_EQ_2(expr1, expr2)                                            \
234
    HPX_TEST_EQ_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
235
#define HPX_TEST_EQ_3(strm, expr1, expr2)                                      \
236
    HPX_TEST_EQ_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
237

238
#define HPX_TEST_EQ_IMPL(fixture, expr1, expr2)                                \
239
    fixture.check_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
240
        ::hpx::util::counter_type::test, expr1, expr2,                         \
241
        "test '" HPX_PP_STRINGIZE(expr1) " == " HPX_PP_STRINGIZE(expr2) "'")
242

243
////////////////////////////////////////////////////////////////////////////////
244
#define HPX_TEST_NEQ(...)                                                      \
245
    HPX_TEST_NEQ_(__VA_ARGS__)                                                 \
246
    /**/
247

248
#define HPX_TEST_NEQ_(...)                                                     \
249
    HPX_PP_EXPAND(                                                             \
250
        HPX_PP_CAT(HPX_TEST_NEQ_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))     \
251
    /**/
252
#define HPX_TEST_NEQ_2(expr1, expr2)                                           \
253
    HPX_TEST_NEQ_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
254
#define HPX_TEST_NEQ_3(strm, expr1, expr2)                                     \
255
    HPX_TEST_NEQ_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
256

257
#define HPX_TEST_NEQ_IMPL(fixture, expr1, expr2)                               \
258
    fixture.check_not_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,   \
259
        ::hpx::util::counter_type::test, expr1, expr2,                         \
260
        "test '" HPX_PP_STRINGIZE(expr1) " != " HPX_PP_STRINGIZE(expr2) "'")
261

262
////////////////////////////////////////////////////////////////////////////////
263
#define HPX_TEST_LT(...)                                                       \
264
    HPX_TEST_LT_(__VA_ARGS__)                                                  \
265
    /**/
266

267
#define HPX_TEST_LT_(...)                                                      \
268
    HPX_PP_EXPAND(                                                             \
269
        HPX_PP_CAT(HPX_TEST_LT_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))      \
270
    /**/
271
#define HPX_TEST_LT_2(expr1, expr2)                                            \
272
    HPX_TEST_LT_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
273
#define HPX_TEST_LT_3(strm, expr1, expr2)                                      \
274
    HPX_TEST_LT_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
275

276
#define HPX_TEST_LT_IMPL(fixture, expr1, expr2)                                \
277
    fixture.check_less(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,        \
278
        ::hpx::util::counter_type::test, expr1, expr2,                         \
279
        "test '" HPX_PP_STRINGIZE(expr1) " < " HPX_PP_STRINGIZE(expr2) "'")
280

281
////////////////////////////////////////////////////////////////////////////////
282
#define HPX_TEST_LTE(...)                                                      \
283
    HPX_TEST_LTE_(__VA_ARGS__)                                                 \
284
    /**/
285

286
#define HPX_TEST_LTE_(...)                                                     \
287
    HPX_PP_EXPAND(                                                             \
288
        HPX_PP_CAT(HPX_TEST_LTE_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))     \
289
    /**/
290
#define HPX_TEST_LTE_2(expr1, expr2)                                           \
291
    HPX_TEST_LTE_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
292
#define HPX_TEST_LTE_3(strm, expr1, expr2)                                     \
293
    HPX_TEST_LTE_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
294

295
#define HPX_TEST_LTE_IMPL(fixture, expr1, expr2)                               \
296
    fixture.check_less_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,  \
297
        ::hpx::util::counter_type::test, expr1, expr2,                         \
298
        "test '" HPX_PP_STRINGIZE(expr1) " <= " HPX_PP_STRINGIZE(expr2) "'")
299

300
////////////////////////////////////////////////////////////////////////////////
301
#define HPX_TEST_RANGE(...)                                                    \
302
    HPX_TEST_RANGE_(__VA_ARGS__)                                               \
303
    /**/
304

305
#define HPX_TEST_RANGE_(...)                                                   \
306
    HPX_PP_EXPAND(                                                             \
307
        HPX_PP_CAT(HPX_TEST_RANGE_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))   \
308
    /**/
309
#define HPX_TEST_RANGE_3(expr1, expr2, expr3)                                  \
310
    HPX_TEST_RANGE_IMPL(                                                       \
311
        ::hpx::util::detail::global_fixture(), expr1, expr2, expr3)
312
#define HPX_TEST_RANGE_4(strm, expr1, expr2, expr3)                            \
313
    HPX_TEST_RANGE_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2, expr3)
314

315
#define HPX_TEST_RANGE_IMPL(fixture, expr1, expr2, expr3)                      \
316
    fixture.check_range(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
317
        ::hpx::util::counter_type::test, expr1, expr2, expr3,                  \
318
        "test '" HPX_PP_STRINGIZE(expr2) " <= " HPX_PP_STRINGIZE(              \
319
            expr1) " <= " HPX_PP_STRINGIZE(expr3) "'")
320

321
////////////////////////////////////////////////////////////////////////////////
322
#define HPX_TEST_EQ_MSG(...)                                                   \
323
    HPX_TEST_EQ_MSG_(__VA_ARGS__)                                              \
324
    /**/
325

326
#define HPX_TEST_EQ_MSG_(...)                                                  \
327
    HPX_PP_EXPAND(                                                             \
328
        HPX_PP_CAT(HPX_TEST_EQ_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))  \
329
    /**/
330
#define HPX_TEST_EQ_MSG_3(expr1, expr2, msg)                                   \
331
    HPX_TEST_EQ_MSG_IMPL(                                                      \
332
        ::hpx::util::detail::global_fixture(), expr1, expr2, msg)
333
#define HPX_TEST_EQ_MSG_4(strm, expr1, expr2, msg)                             \
334
    HPX_TEST_EQ_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2, msg)
335

336
#define HPX_TEST_EQ_MSG_IMPL(fixture, expr1, expr2, msg)                       \
337
    fixture.check_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
338
        ::hpx::util::counter_type::test, expr1, expr2, msg)
339

340
////////////////////////////////////////////////////////////////////////////////
341
#define HPX_TEST_NEQ_MSG(...)                                                  \
342
    HPX_TEST_NEQ_MSG_(__VA_ARGS__)                                             \
343
    /**/
344

345
#define HPX_TEST_NEQ_MSG_(...)                                                 \
346
    HPX_PP_EXPAND(                                                             \
347
        HPX_PP_CAT(HPX_TEST_NEQ_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__)) \
348
    /**/
349
#define HPX_TEST_NEQ_MSG_3(expr1, expr2, msg)                                  \
350
    HPX_TEST_NEQ_MSG_IMPL(                                                     \
351
        ::hpx::util::detail::global_fixture(), expr1, expr2, msg)
352
#define HPX_TEST_NEQ_MSG_4(strm, expr1, expr2, msg)                            \
353
    HPX_TEST_NEQ_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2, msg)
354

355
#define HPX_TEST_NEQ_MSG_IMPL(fixture, expr1, expr2, msg)                      \
356
    fixture.check_not_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,   \
357
        ::hpx::util::counter_type::test, expr1, expr2, msg)
358

359
////////////////////////////////////////////////////////////////////////////////
360
#define HPX_TEST_LT_MSG(...)                                                   \
361
    HPX_TEST_LT_MSG_(__VA_ARGS__)                                              \
362
    /**/
363

364
#define HPX_TEST_LT_MSG_(...)                                                  \
365
    HPX_PP_EXPAND(                                                             \
366
        HPX_PP_CAT(HPX_TEST_LT_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))  \
367
    /**/
368
#define HPX_TEST_LT_MSG_3(expr1, expr2, msg)                                   \
369
    HPX_TEST_LT_MSG_IMPL(                                                      \
370
        ::hpx::util::detail::global_fixture(), expr1, expr2, msg)
371
#define HPX_TEST_LT_MSG_4(strm, expr1, expr2, msg)                             \
372
    HPX_TEST_LT_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2, msg)
373

374
#define HPX_TEST_LT_MSG_IMPL(fixture, expr1, expr2, msg)                       \
375
    fixture.check_less(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,        \
376
        ::hpx::util::counter_type::test, expr1, expr2, msg)
377

378
////////////////////////////////////////////////////////////////////////////////
379
#define HPX_TEST_LTE_MSG(...)                                                  \
380
    HPX_TEST_LTE_MSG_(__VA_ARGS__)                                             \
381
    /**/
382

383
#define HPX_TEST_LTE_MSG_(...)                                                 \
384
    HPX_PP_EXPAND(                                                             \
385
        HPX_PP_CAT(HPX_TEST_LTE_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__)) \
386
    /**/
387
#define HPX_TEST_LTE_MSG_3(expr1, expr2, msg)                                  \
388
    HPX_TEST_LTE_MSG_IMPL(                                                     \
389
        ::hpx::util::detail::global_fixture(), expr1, expr2, msg)
390
#define HPX_TEST_LTE_MSG_4(strm, expr1, expr2, msg)                            \
391
    HPX_TEST_LTE_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2, msg)
392

393
#define HPX_TEST_LTE_MSG_IMPL(fixture, expr1, expr2, msg)                      \
394
    fixture.check_less_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,  \
395
        ::hpx::util::counter_type::test, expr1, expr2, msg)
396

397
////////////////////////////////////////////////////////////////////////////////
398
#define HPX_TEST_RANGE_MSG(...)                                                \
399
    HPX_TEST_RANGE_MSG_(__VA_ARGS__)                                           \
400
    /**/
401

402
#define HPX_TEST_RANGE_MSG_(...)                                               \
403
    HPX_PP_EXPAND(HPX_PP_CAT(HPX_TEST_RANGE_MSG_, HPX_PP_NARGS(__VA_ARGS__))(  \
404
        __VA_ARGS__))                                                          \
405
    /**/
406
#define HPX_TEST_RANGE_MSG_4(expr1, expr2, expr3, msg)                         \
407
    HPX_TEST_RANGE_MSG_IMPL(                                                   \
408
        ::hpx::util::detail::global_fixture(), expr1, expr2, expr3, msg)
409
#define HPX_TEST_RANGE_MSG_5(strm, expr1, expr2, expr3, msg)                   \
410
    HPX_TEST_RANGE_MSG_IMPL(                                                   \
411
        ::hpx::util::detail::fixture{strm}, expr1, expr2, expr3, msg)
412

413
#define HPX_TEST_RANGE_MSG_IMPL(fixture, expr1, expr2, expr3, msg)             \
414
    fixture.check_range(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
415
        ::hpx::util::counter_type::test, expr1, expr2, expr3, msg)
416

417
////////////////////////////////////////////////////////////////////////////////
418
#define HPX_SANITY(...)                                                        \
419
    HPX_SANITY_(__VA_ARGS__)                                                   \
420
    /**/
421

422
#define HPX_SANITY_(...)                                                       \
423
    HPX_PP_EXPAND(                                                             \
424
        HPX_PP_CAT(HPX_SANITY_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))       \
425
    /**/
426
#define HPX_SANITY_1(expr)                                                     \
427
    HPX_TEST_IMPL(::hpx::util::detail::global_fixture(), expr)
428
#define HPX_SANITY_2(strm, expr)                                               \
429
    HPX_SANITY_IMPL(::hpx::util::detail::fixture{strm}, expr)
430

431
#define HPX_SANITY_IMPL(fixture, expr)                                         \
432
    fixture.check_(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,            \
433
        ::hpx::util::counter_type::sanity, expr,                               \
434
        "sanity check '" HPX_PP_STRINGIZE(expr) "'")
435

436
////////////////////////////////////////////////////////////////////////////////
437
#define HPX_SANITY_MSG(...)                                                    \
438
    HPX_SANITY_MSG_(__VA_ARGS__)                                               \
439
    /**/
440

441
#define HPX_SANITY_MSG_(...)                                                   \
442
    HPX_PP_EXPAND(                                                             \
443
        HPX_PP_CAT(HPX_SANITY_MSG_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))   \
444
    /**/
445
#define HPX_SANITY_MSG_2(expr, msg)                                            \
446
    HPX_SANITY_MSG_IMPL(::hpx::util::detail::global_fixture(), expr, msg)
447
#define HPX_SANITY_MSG_3(strm, expr, msg)                                      \
448
    HPX_SANITY_MSG_IMPL(::hpx::util::detail::fixture{strm}, expr, msg)
449

450
#define HPX_SANITY_MSG_IMPL(fixture, expr, msg)                                \
451
    fixture.check_(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,            \
452
        ::hpx::util::counter_type::sanity, expr, msg)
453

454
////////////////////////////////////////////////////////////////////////////////
455
#define HPX_SANITY_EQ(...)                                                     \
456
    HPX_SANITY_EQ_(__VA_ARGS__)                                                \
457
    /**/
458

459
#define HPX_SANITY_EQ_(...)                                                    \
460
    HPX_PP_EXPAND(                                                             \
461
        HPX_PP_CAT(HPX_SANITY_EQ_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))    \
462
    /**/
463
#define HPX_SANITY_EQ_2(expr1, expr2)                                          \
464
    HPX_SANITY_EQ_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
465
#define HPX_SANITY_EQ_3(strm, expr1, expr2)                                    \
466
    HPX_SANITY_EQ_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
467

468
#define HPX_SANITY_EQ_IMPL(fixture, expr1, expr2)                              \
469
    fixture.check_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
470
        ::hpx::util::counter_type::sanity, expr1, expr2,                       \
471
        "sanity check '" HPX_PP_STRINGIZE(expr1) " == " HPX_PP_STRINGIZE(      \
472
            expr2) "'")
473

474
////////////////////////////////////////////////////////////////////////////////
475
#define HPX_SANITY_NEQ(...)                                                    \
476
    HPX_SANITY_NEQ_(__VA_ARGS__)                                               \
477
    /**/
478

479
#define HPX_SANITY_NEQ_(...)                                                   \
480
    HPX_PP_EXPAND(                                                             \
481
        HPX_PP_CAT(HPX_SANITY_NEQ_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))   \
482
    /**/
483
#define HPX_SANITY_NEQ_2(expr1, expr2)                                         \
484
    HPX_SANITY_NEQ_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
485
#define HPX_SANITY_NEQ_3(strm, expr1, expr2)                                   \
486
    HPX_SANITY_NEQ_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
487

488
#define HPX_SANITY_NEQ_IMPL(fixture, expr1, expr2)                             \
489
    fixture.check_not_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,   \
490
        ::hpx::util::counter_type::sanity, expr1, expr2,                       \
491
        "sanity check '" HPX_PP_STRINGIZE(expr1) " != " HPX_PP_STRINGIZE(      \
492
            expr2) "'")
493

494
////////////////////////////////////////////////////////////////////////////////
495
#define HPX_SANITY_LT(...)                                                     \
496
    HPX_SANITY_LT_(__VA_ARGS__)                                                \
497
    /**/
498

499
#define HPX_SANITY_LT_(...)                                                    \
500
    HPX_PP_EXPAND(                                                             \
501
        HPX_PP_CAT(HPX_SANITY_LT_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))    \
502
    /**/
503
#define HPX_SANITY_LT_2(expr1, expr2)                                          \
504
    HPX_SANITY_LT_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
505
#define HPX_SANITY_LT_3(strm, expr1, expr2)                                    \
506
    HPX_SANITY_LT_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
507

508
#define HPX_SANITY_LT_IMPL(fixture, expr1, expr2)                              \
509
    fixture.check_less(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,        \
510
        ::hpx::util::counter_type::sanity, expr1, expr2,                       \
511
        "sanity check '" HPX_PP_STRINGIZE(expr1) " < " HPX_PP_STRINGIZE(       \
512
            expr2) "'")
513

514
////////////////////////////////////////////////////////////////////////////////
515
#define HPX_SANITY_LTE(...)                                                    \
516
    HPX_SANITY_LTE_(__VA_ARGS__)                                               \
517
    /**/
518

519
#define HPX_SANITY_LTE_(...)                                                   \
520
    HPX_PP_EXPAND(                                                             \
521
        HPX_PP_CAT(HPX_SANITY_LTE_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))   \
522
    /**/
523
#define HPX_SANITY_LTE_2(expr1, expr2)                                         \
524
    HPX_SANITY_LTE_IMPL(::hpx::util::detail::global_fixture(), expr1, expr2)
525
#define HPX_SANITY_LTE_3(strm, expr1, expr2)                                   \
526
    HPX_SANITY_LTE_IMPL(::hpx::util::detail::fixture{strm}, expr1, expr2)
527

528
#define HPX_SANITY_LTE_IMPL(fixture, expr1, expr2)                             \
529
    fixture.check_less_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,  \
530
        ::hpx::util::counter_type::sanity, expr1, expr2,                       \
531
        "sanity check '" HPX_PP_STRINGIZE(expr1) " <= " HPX_PP_STRINGIZE(      \
532
            expr2) "'")
533

534
////////////////////////////////////////////////////////////////////////////////
535
#define HPX_SANITY_RANGE(...)                                                  \
536
    HPX_SANITY_RANGE_(__VA_ARGS__)                                             \
537
    /**/
538

539
#define HPX_SANITY_RANGE_(...)                                                 \
540
    HPX_PP_EXPAND(                                                             \
541
        HPX_PP_CAT(HPX_SANITY_RANGE_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__)) \
542
    /**/
543
#define HPX_SANITY_RANGE_3(expr1, expr2, expr3)                                \
544
    HPX_SANITY_RANGE_IMPL(                                                     \
545
        ::hpx::util::detail::global_fixture(), expr1, expr2, expr3)
546
#define HPX_SANITY_RANGE_4(strm, expr1, expr2, expr3)                          \
547
    HPX_SANITY_RANGE_IMPL(                                                     \
548
        ::hpx::util::detail::fixture{strm}, expr1, expr2, expr3)
549

550
#define HPX_SANITY_RANGE_IMPL(fixture, expr1, expr2, expr3)                    \
551
    fixture.check_range(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
552
        ::hpx::util::counter_type::sanity, expr1, expr2, expr3,                \
553
        "sanity check '" HPX_PP_STRINGIZE(expr2) " <= " HPX_PP_STRINGIZE(      \
554
            expr1) " <= " HPX_PP_STRINGIZE(expr3) "'")
555

556
////////////////////////////////////////////////////////////////////////////////
557
#define HPX_SANITY_EQ_MSG(...)                                                 \
558
    HPX_SANITY_EQ_MSG_(__VA_ARGS__)                                            \
559
    /**/
560

561
#define HPX_SANITY_EQ_MSG_(...)                                                \
562
    HPX_PP_EXPAND(HPX_PP_CAT(HPX_SANITY_EQ_MSG_, HPX_PP_NARGS(__VA_ARGS__))(   \
563
        __VA_ARGS__))                                                          \
564
    /**/
565
#define HPX_SANITY_EQ_MSG_3(expr1, expr2, msg)                                 \
566
    HPX_SANITY_EQ_MSG_IMPL(                                                    \
567
        ::hpx::util::detail::global_fixture(), expr1, expr2, msg)
568
#define HPX_SANITY_EQ_MSG_4(strm, expr1, expr2, msg)                           \
569
    HPX_SANITY_EQ_MSG_IMPL(                                                    \
570
        ::hpx::util::detail::fixture{strm}, expr1, expr2, msg)
571

572
#define HPX_SANITY_EQ_MSG_IMPL(fixture, expr1, expr2, msg)                     \
573
    fixture.check_equal(__FILE__, __LINE__, HPX_ASSERT_CURRENT_FUNCTION,       \
574
        ::hpx::util::counter_type::sanity, expr1, expr2, msg)
575

576
////////////////////////////////////////////////////////////////////////////////
577
#define HPX_TEST_THROW(...)                                                    \
578
    HPX_TEST_THROW_(__VA_ARGS__)                                               \
579
    /**/
580

581
#define HPX_TEST_THROW_(...)                                                   \
582
    HPX_PP_EXPAND(                                                             \
583
        HPX_PP_CAT(HPX_TEST_THROW_, HPX_PP_NARGS(__VA_ARGS__))(__VA_ARGS__))   \
584
    /**/
585
#define HPX_TEST_THROW_2(expression, exception)                                \
586
    HPX_TEST_THROW_IMPL(                                                       \
587
        ::hpx::util::detail::global_fixture(), expression, exception)
588
#define HPX_TEST_THROW_3(strm, expression, exception)                          \
589
    HPX_TEST_THROW_IMPL(                                                       \
590
        ::hpx::util::detail::fixture{strm}, expression, exception)
591

592
#define HPX_TEST_THROW_IMPL(fixture, expression, exception)                    \
593
    {                                                                          \
594
        bool caught_exception = false;                                         \
595
        try                                                                    \
596
        {                                                                      \
597
            expression;                                                        \
598
            HPX_TEST_MSG_IMPL(                                                 \
599
                fixture, false, "expected exception not thrown");              \
600
        }                                                                      \
601
        catch (exception&)                                                     \
602
        {                                                                      \
603
            caught_exception = true;                                           \
604
        }                                                                      \
605
        catch (...)                                                            \
606
        {                                                                      \
607
            HPX_TEST_MSG_IMPL(fixture, false, "unexpected exception caught");  \
608
        }                                                                      \
609
        HPX_TEST_IMPL(fixture, caught_exception);                              \
610
    }                                                                          \
611
    /**/
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc