41 CheckResult(std::string message);
42 CheckResult(std::string exected, std::string actual);
44 CheckResult(
const CheckResult&) =
delete;
45 CheckResult(CheckResult&&);
49 CheckResult& operator << (const std::vector<std::string>&);
58 bool error()
const {
return reportError_; }
59 void cancel() { reportError_ =
false; }
61 std::string expected()
const {
return expected_; }
62 std::string actual()
const {
return actual_; }
63 std::string message()
const {
return message_.str(); }
68 const std::string expected_;
69 const std::string actual_;
71 std::ostringstream message_;
75 CheckResult
operator && (CheckResult&&, CheckResult&&);
78 CheckResult
operator && (CheckResult&&, CheckResult&);
81 CheckResult
operator || (CheckResult&&, CheckResult&&);
84 CheckResult
operator || (CheckResult&&, CheckResult&);
92 CheckResult
Check(
bool, std::string description);
95 CheckResult
CheckInt(
int expected,
int actual);
98 CheckResult
CheckFloat(
double exp,
double act,
double tolerance = 0.000001);
108 CheckResult
CheckString(std::string expected, std::string actual,
109 size_t maxEditDistance = 0);
164 std::string name =
"<unnamed test>",
166 std::ostream& errorStream = std::cerr);
186 std::string name =
"<unnamed test>",
188 std::ostream& errorStream = std::cerr)
191 T *testOutput =
static_cast<T*
>(mem->
rawPointer());
194 RunTest([&]() {
return test(*testOutput); }, name,
195 timeout, errorStream);
197 output = *testOutput;
218 template<
class Expectation,
class Output>
220 const Expectation& expect, Output& output,
221 std::string name =
"<unnamed test>", time_t timeout = 0,
222 std::ostream& errorStream = std::cerr)
224 using std::placeholders::_1;
225 return RunTest<Output>(
226 std::bind(t, expect, _1), output, name, timeout, errorStream);
the test took too long to run
virtual void * rawPointer() const =0
A pointer to the shared memory, which will be invalidated after this object is destructed.
TestResult
The result of running one test within a separate process.
CheckResult CheckInt(int expected, int actual)
Check that two integers are equal, failing the test if they are not.
std::unique_ptr< SharedMemory > MapSharedData(size_t size)
Map data into the address space that can be shared with other processes.
CheckResult Check(bool, std::string description)
Check an arbitrary condition, failing the test if false.
CheckResult operator||(CheckResult &&, CheckResult &&)
Combine the results of two checks using a sum (OR): at least one must pass.
the test caused a segmentation fault
CheckResult CheckString(std::string expected, std::string actual, size_t maxEditDistance=0)
Check that two strings are (approximately) equal.
std::ostream & operator<<(std::ostream &, TestResult)
Output a human-readable representation of a TestResult.
A representation of a shared memory object.
CheckResult operator&&(CheckResult &&, CheckResult &&)
Combine the results of two checks using a product (AND): both must pass.
CheckResult CheckFloat(double exp, double act, double tolerance=0.000001)
Check that two floating-point numbers are equal within some tolerance.
TestResult RunTest(std::function< TestResult()> test, std::string name="<unnamed test>", time_t timeout=0, std::ostream &errorStream=std::cerr)
Run a test closure in a separate process, capturing segmentation faults and other errors that lead to...
the test terminated for another reason
Container for all libgrading names.