diff --git a/Makefile b/Makefile index c1ff0e3..4f1105e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ EXE=test-shunting-yard -SRC=$(EXE).cpp shunting-yard.cpp packToken.cpp +SRC=$(EXE).cpp shunting-yard.cpp packToken.cpp catch.cpp OBJ=$(SRC:.cpp=.o) CXX=g++ diff --git a/catch.cpp b/catch.cpp new file mode 100644 index 0000000..272551a --- /dev/null +++ b/catch.cpp @@ -0,0 +1,10 @@ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +// Defined on test-shunting-yard.cpp +void PREPARE_ENVIRONMENT(); + +int main(int argc, char** argv) { + PREPARE_ENVIRONMENT(); + return Catch::Session().run(argc, argv); +} \ No newline at end of file diff --git a/test-shunting-yard.cpp b/test-shunting-yard.cpp index 1146c52..939c762 100644 --- a/test-shunting-yard.cpp +++ b/test-shunting-yard.cpp @@ -1,10 +1,10 @@ -#define CATCH_CONFIG_RUNNER #include "catch.hpp" #include "./shunting-yard.h" -TokenMap_t vars, tmap, emap, key3; -int main(int argc, char** argv) { +TokenMap_t vars, tmap, key3, emap; + +void PREPARE_ENVIRONMENT() { vars["pi"] = 3.14; vars["b1"] = 0.0; vars["b2"] = 0.86; @@ -24,9 +24,6 @@ int main(int argc, char** argv) { emap["a"] = 10; emap["b"] = 20; - - int result = Catch::Session().run(argc, argv); - return result; } TEST_CASE("Static calculate::calculate()") {