-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathmain.cpp
39 lines (34 loc) · 1.25 KB
/
main.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
/** @file
* This file is left mostly empty so that catch doesn't need
* slow (~16s) recompilation each time unit tests are edited
*
* @author Tyson Jones
*/
/** Use our modified Catch in custom-main mode (main defined below).
* catch.hpp was modified to, in distributed mode, output only once.
*/
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
#include "QuEST.h"
/** The global QuESTEnv instance, to be created and destroyed once in this
* main(), so that the MPI environment is correctly created once when running
* distributed unit tests
*/
QuESTEnv QUEST_ENV;
/** Redefinition of QuEST_validation's invalidQuESTInputError function, called when a
* user passes an incorrect parameter (e.g. an negative qubit index). This is
* redefined here to, in lieu of printing and exiting, throw a C++ exception
* which can be caught (and hence unit tested for) by Catch2
*/
extern "C" void invalidQuESTInputError(const char* errMsg, const char* errFunc) {
throw errMsg;
}
/** Explicit declaration of main to create (destroy) the QuESTEnv before (after)
* invoking the Catch unit tests
*/
int main( int argc, char* argv[] ) {
QUEST_ENV = createQuESTEnv();
int result = Catch::Session().run( argc, argv );
destroyQuESTEnv(QUEST_ENV);
return result;
}