The Quantum Exact Simulation Toolkit v4.2.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#include "quest.h"
21#include "test_utilities.hpp"
22
23#include <stdexcept>
24
25
26
27/*
28 * recast QuEST errors into exceptions which Catch2 can intercept
29 */
30
31/// @private
32extern "C" void validationErrorHandler(const char* errFunc, const char* errMsg) {
33
34 throw std::runtime_error(std::string(errFunc) + ": " + std::string(errMsg));
35}
36
37
38/** Explicit declaration of main to create (destroy) the QuESTEnv before (after)
39 * invoking the Catch unit tests
40 */
41int main(int argc, char* argv[]) {
42
44 setInputErrorHandler(validationErrorHandler);
45 setRandomTestStateSeeds();
46
47 int result = Catch::Session().run( argc, argv );
48
50 return result;
51}
void setInputErrorHandler(void(*callback)(const char *func, const char *msg))
Definition debug.cpp:74
void finalizeQuESTEnv()
void initQuESTEnv()