The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches
test_main.cpp
1/** @file
2 * Entry-point for the ported tests of QuEST's deprecated
3 * v3 API.
4 *
5 * This file was originally written for catch2 v2, though has
6 * since been refactored for compatibility with catch2 v3. The
7 * comments however have not been updated and may mislead.
8 *
9 * @author Tyson Jones
10 * @author Oliver Thomson Brown (ported to Catch2 v3)
11 * @author Ali Rezaei (tested porting to QuEST v4)
12 */
13
14
15/** Use our modified Catch in custom-main mode (main defined below).
16 * catch.hpp was modified to, in distributed mode, output only once.
17 */
18#include <catch2/catch_session.hpp>
19
20
21#define INCLUDE_DEPRECATED_FUNCTIONS 1
22#define DISABLE_DEPRECATION_WARNINGS 1
23
24#include "quest/include/quest.h"
25#include "test_utilities.hpp"
26
27#include <stdexcept>
28
29
30
31/*
32 * recast QuEST errors into exceptions which Catch2 can intercept
33 */
34
35/// @private
36extern "C" void validationErrorHandler(const char* errFunc, const char* errMsg) {
37
38 throw std::runtime_error(std::string(errFunc) + ": " + std::string(errMsg));
39}
40
41
42/** Explicit declaration of main to create (destroy) the QuESTEnv before (after)
43 * invoking the Catch unit tests
44 */
45int main(int argc, char* argv[]) {
46
48 setInputErrorHandler(validationErrorHandler);
49 setRandomTestStateSeeds();
50
51 int result = Catch::Session().run( argc, argv );
52
54 return result;
55}
void setInputErrorHandler(void(*callback)(const char *func, const char *msg))
Definition debug.cpp:74
void finalizeQuESTEnv()
void initQuESTEnv()