CoolProp  6.6.1dev
An open-source fluid property and humid air property database
Tests.cpp
Go to the documentation of this file.
1 
7 #include "Tests.h"
8 #include "time.h"
9 
10 #if defined ENABLE_CATCH
11 # include <catch2/catch_all.hpp>
12 
13 static Catch::Session session; // There must be exactly one instance
14 
15 #endif // ENABLE_CATCH
16 
18 #ifdef ENABLE_CATCH
19  Catch::ConfigData& config = session.configData();
20  config.testsOrTags.clear();
21  config.testsOrTags.push_back("[fast]");
22  session.useConfigData(config);
23  return session.run();
24 #else
25  return 0;
26 #endif
27 }
28 
30 #ifdef ENABLE_CATCH
31  Catch::ConfigData& config = session.configData();
32  config.testsOrTags.clear();
33  config.testsOrTags.push_back("~[slow]");
34  session.useConfigData(config);
35 
36  time_t t1, t2;
37  t1 = clock();
38  session.run();
39  t2 = clock();
40  printf("Elapsed time for not slow tests: %g s", (double)(t2 - t1) / CLOCKS_PER_SEC);
41 
42  return 1;
43 #else
44  return 0;
45 #endif
46 }
47 
48 int run_user_defined_tests(const std::vector<std::string>& tests_or_tags) {
49 #ifdef ENABLE_CATCH
50  Catch::ConfigData& config = session.configData();
51  config.testsOrTags.clear();
52  for (unsigned int i = 0; i < tests_or_tags.size(); i++) {
53  config.testsOrTags.push_back(tests_or_tags[i]);
54  }
55  session.useConfigData(config);
56 
57  time_t t1, t2;
58  t1 = clock();
59  session.run();
60  t2 = clock();
61  printf("Elapsed time for user defined tests: %g s", (double)(t2 - t1) / CLOCKS_PER_SEC);
62 
63  return 1;
64 #else
65  return 0;
66 #endif
67 }
68 
69 void run_tests() {
70 #ifdef ENABLE_CATCH
71  Catch::ConfigData& config = session.configData();
72  config.testsOrTags.clear();
73  //config.shouldDebugBreak = true;
74  session.useConfigData(config);
75  session.run();
76 #endif
77 }