2#ifndef STORMM_UNIT_TEST_H
3#define STORMM_UNIT_TEST_H
11#include "DataTypes/common_types.h"
12#include "DataTypes/stormm_vector_types.h"
13#include "Parsing/polynumeric.h"
14#include "Parsing/textfile.h"
15#include "Reporting/error_format.h"
16#include "Math/summation.h"
17#include "Math/vector_ops.h"
20#include "file_snapshot.h"
21#include "test_environment.h"
22#include "vector_report.h"
30#define CHECK_THROWS(test_code, error_message) {\
31 bool exception_thrown = false;\
35 catch (std::runtime_error) {\
36 exception_thrown = true;\
38 check(exception_thrown, error_message);\
50#define CHECK_THROWS_SOFT(test_code, error_message, priority) {\
51 if (priority == stormm::testing::TestPriority::ABORT) {\
52 check(true, error_message, priority);\
55 bool exception_thrown = false;\
59 catch (std::runtime_error) {\
60 exception_thrown = true;\
62 check(exception_thrown, error_message, priority);\
70using errors::terminalFormat;
71using data_types::isScalarType;
72using data_types::isSignedIntegralScalarType;
73using data_types::isUnsignedIntegralScalarType;
74using data_types::isFloatingPointScalarType;
76using stmath::maxAbsoluteDifference;
77using stmath::maxRelativeDifference;
78using stmath::meanUnsignedError;
79using stmath::relativeRmsError;
80using parse::NumberFormat;
81using parse::polyNumericVector;
92void section(
const std::string §ion_name);
93void section(
const int section_index);
99int unitTestSectionIndex(
const std::string &name);
104std::string unitTestSectionName(
int index);
128CheckResult check(
const bool statement,
const std::string &error_message =
"",
129 TestPriority urgency = TestPriority::CRITICAL);
131CheckResult check(
double lhs, RelationalOperator relationship,
const Approx &rhs,
132 const std::string &error_message, TestPriority urgency = TestPriority::CRITICAL);
134CheckResult check(
const Approx &lhs, RelationalOperator relationship,
const double rhs,
135 const std::string &error_message, TestPriority urgency = TestPriority::CRITICAL);
137CheckResult check(
const double lhs, RelationalOperator relationship,
const double rhs,
138 const std::string &error_message, TestPriority urgency = TestPriority::CRITICAL);
140CheckResult check(
const std::string &lhs, RelationalOperator relationship,
141 const std::string &rhs,
const std::string &error_message,
142 TestPriority urgency = TestPriority::CRITICAL);
144CheckResult check(
const char4 &lhs, RelationalOperator relationship,
const char4 &rhs,
145 const std::string &error_message, TestPriority urgency = TestPriority::CRITICAL);
147CheckResult check(
const std::vector<char4> &lhs, RelationalOperator relationship,
148 const std::vector<char4> &rhs,
const std::string &error_message,
149 TestPriority urgency = TestPriority::CRITICAL);
159CheckResult check(
const std::vector<T> &lhs, RelationalOperator relationship,
160 const Approx &rhs,
const std::string &error_message,
161 TestPriority urgency = TestPriority::CRITICAL);
171CheckResult check(
const Approx &lhs,
const RelationalOperator relationship,
172 const std::vector<T> &rhs,
const std::string &error_message,
173 TestPriority urgency = TestPriority::CRITICAL);
178template <
typename T1,
typename T2>
179CheckResult check(
const std::vector<T1> &lhs,
const RelationalOperator relationship,
180 const std::vector<T2> &rhs,
const std::string &error_message,
181 TestPriority urgency = TestPriority::CRITICAL);
213CheckResult snapshot(
const std::string &filename,
const std::vector<PolyNumeric> &content,
214 const std::string &label = std::string(
""),
215 double comparison_tolerance = 1.0e-4,
216 const std::string &error_message = std::string(
""),
217 SnapshotOperation activity = SnapshotOperation::COMPARE,
218 double output_precision = 1.0e-8,
219 NumberFormat data_format = NumberFormat::STANDARD_REAL,
220 PrintSituation expectation = PrintSituation::OVERWRITE,
221 TestPriority urgency = TestPriority::CRITICAL);
223CheckResult snapshot(
const std::string &filename,
const std::vector<PolyNumeric> &content,
224 const std::string &label = std::string(
""),
225 NumberFormat data_format = NumberFormat::STANDARD_REAL,
226 const std::string &error_message = std::string(
""),
227 SnapshotOperation activity = SnapshotOperation::COMPARE,
228 double comparison_tolerance = 1.0e-4,
double output_precision = 1.0e-8,
229 PrintSituation expectation = PrintSituation::OVERWRITE,
230 TestPriority urgency = TestPriority::CRITICAL);
232CheckResult snapshot(
const std::string &filename,
const TextFile &content,
233 const std::string &label = std::string(
""),
234 const std::string &error_message = std::string(
""),
235 const SnapshotOperation activity = SnapshotOperation::COMPARE,
236 const PrintSituation expectation = PrintSituation::OVERWRITE,
237 const TestPriority urgency = TestPriority::CRITICAL,
238 int comparison_tolerance = 0);
240CheckResult snapshot(
const std::string &filename,
const std::string &content,
241 const std::string &label = std::string(
""),
242 const std::string &error_message = std::string(
""),
243 const SnapshotOperation activity = SnapshotOperation::COMPARE,
244 const PrintSituation expectation = PrintSituation::OVERWRITE,
245 const TestPriority urgency = TestPriority::CRITICAL,
246 int comparison_tolerance = 0);
252void printTestSummary(TestVerbosity tv);
255int countGlobalTestFailures();
260std::string getRelationalOperatorString(RelationalOperator ro);
269#include "unit_test.tpp"
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45
Class for handling comparisons of floating-point results versus expected values in unit tests....
Definition approx.h:23
Object for storing a series of test results, with labels.
Definition checklist.h:14