The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
macros.hpp
1/** @file
2 * @author Tyson Jones
3 *
4 * @defgroup testutilsmacros Macros
5 * @ingroup testutils
6 * @brief
7 * Macros used by the tests and testing utilities.
8 * @{
9 */
10
11#ifndef MACROS_HPP
12#define MACROS_HPP
13
14#include <catch2/catch_test_macros.hpp>
15
16
17/**
18 * macros which affect the speed and rigour of the unit tests, useful
19 * for accelerating tests on particular platforms (e.g. paid github runners).
20 * The default values are those which perform the most rigorous tests at
21 * the slowest speed, so adjusting these macros accelerates tests.
22 *
23 * @todo
24 * These are clunky preprocessors (invoking full recompilation when changed),
25 * rather than runtime arguments, because of the nuisance of passing such
26 * args to cmake. It can be done however using environment variables; see
27 * https://stackoverflow.com/questions/28812533/
28 */
29
30// 0 = perform all, and a sensible value to accelerate tests is 50
31#ifndef TEST_MAX_NUM_QUBIT_PERMUTATIONS
32#define TEST_MAX_NUM_QUBIT_PERMUTATIONS 0
33#endif
34
35// 0 = perform all (very slow), while 4 limits to superops = 8-qubit matrices
36#ifndef TEST_MAX_NUM_SUPEROP_TARGETS
37#define TEST_MAX_NUM_SUPEROP_TARGETS 4
38#endif
39
40// 0 = use all available deployments at once, 1 = try all combinations in-turn
41#ifndef TEST_ALL_DEPLOYMENTS
42#define TEST_ALL_DEPLOYMENTS 1
43#endif
44
45// number of times to repeat each "[mixed]" test (minimum 1)
46#ifndef TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS
47#define TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS 10
48#endif
49
50// spoofing above macros as consts to doc
51#if 0
52
53 /// @macrodoc
55
56 /// @macrodoc
58
59 /// @macrodoc
60 const int TEST_ALL_DEPLOYMENTS = 1;
61
62 /// @macrodoc
64
65#endif
66
67
68/*
69 * preconditions to the internal unit testing functions are checked using
70 * DEMAND rather than Catch2's REQUIRE, so that they are not counted in the
71 * total unit testing statistics (e.g. number of checks passed).
72 */
73
74#define DEMAND( cond ) do { if (!(cond)) { FAIL( ); } } while (0)
75
76
77// section labels
78
79#define LABEL_CORRECTNESS "correctness"
80#define LABEL_VALIDATION "validation"
81#define LABEL_STATEVEC "statevector"
82#define LABEL_DENSMATR "densitymatrix"
83#define LABEL_C_INTERFACE "C interface"
84#define LABEL_CPP_INTERFACE "C++ interface"
85
86#define LABEL_DELIMITER ", "
87
88#define LABEL_UNIT_TAG "[unit]"
89#define LABEL_MIXED_DEPLOY_TAG "[mixed]"
90#define LABEL_INTEGRATION_TAG "[integration]"
91
92
93// detect LLVM address sanitizer (on GCC and Clang only)
94#if defined(__SANITIZE_ADDRESS__)
95 #define SANITIZER_IS_ACTIVE
96#elif defined(__has_feature)
97 #if __has_feature(address_sanitizer)
98 #define SANITIZER_IS_ACTIVE
99 #endif
100#endif
101
102
103#endif // MACROS_HPP
104
105/** @} (end defgroup) */
const int TEST_MAX_NUM_SUPEROP_TARGETS
Definition macros.hpp:57
const int TEST_ALL_DEPLOYMENTS
Definition macros.hpp:60
const int TEST_NUM_MIXED_DEPLOYMENT_REPETITIONS
Definition macros.hpp:63
const int TEST_MAX_NUM_QUBIT_PERMUTATIONS
Definition macros.hpp:54