56 "name",
"evaluated",
"failed",
"description"
65 "name",
"evaluated",
"expectedFlags",
"failed"
74 "name",
"thrown",
"correctType",
"failed"
94 std::map<std::string, std::vector<assert_result>> assertResults {};
97 std::map<std::string, std::vector<errno_result>> errnoResults {};
100 std::map<std::string, std::vector<exception_result>> exceptionResults {};
103 bool wasTerminated {
false};
112 std::shared_ptr<output::output_context>
output;
116 std::shared_ptr<random::random_context>
random;
126 const std::string& moduleName,
127 int argc = 0,
const char**
argv =
nullptr) {
131 output = std::make_shared<output::output_context>();
132 random = std::make_shared<random::random_context>();
138 std::cout <<
"Starting error checking on ";
139 std::cout << moduleName <<
" module ..." << std::endl;
142 wasTerminated =
false;
155 for (
const auto&
pair : assertResults) {
162 for (
const auto&
pair : errnoResults) {
169 for (
const auto&
pair : exceptionResults) {
178 !
output->settings.outputFiles.size() &&
187 std::vector<std::string> outputFiles;
243 std::cout <<
" (" << std::setprecision(3) <<
percent <<
"%)" << std::endl;
246 std::cout <<
"\nNo checks were run!" << std::endl;
254 wasTerminated =
true;
260 std::string moduleName,
262 const char**
argv =
nullptr) {
281 const std::string& name,
283 std::string description =
"",
284 bool quiet =
false) {
291 res.description = description;
294 assertResults[name].push_back(
res);
304 template<
typename Function,
typename InputType>
306 const std::string& name,
310 bool quiet =
false) {
316 volatile auto r = f(
x);
326 errnoResults[name].push_back(
res);
336 template<
typename Function,
typename InputType>
338 const std::string& name,
Function f,
341 bool quiet =
false) {
355 template<
typename Function,
typename InputType>
357 const std::string& name,
361 bool quiet =
false) {
368 volatile auto r = f(
x);
382 errnoResults[name].push_back(
res);
394 template<
typename Function,
typename InputType>
396 const std::string& name,
Function f,
399 bool quiet =
false) {
411 template<
typename Function,
typename InputType>
413 const std::string& name,
416 bool quiet =
false) {
422 volatile auto r = f(
x);
430 res.failed = !thrown;
431 res.correctType =
true;
434 exceptionResults[name].push_back(
res);
444 template<
typename Function,
typename InputType>
446 const std::string& name,
Function f,
448 bool quiet =
false) {
450 throws(name, f, generator(), quiet);
466 const std::string& name,
469 bool quiet =
false) {
473 bool correctType =
false;
476 volatile auto r = f(
x);
489 res.failed = !(thrown && correctType);
490 res.correctType = correctType;
493 exceptionResults[name].push_back(
res);
510 const std::string& name,
Function f,
512 bool quiet =
false) {
514 throws(name, f, generator(), quiet);
520 return assertResults[name];
526 return assertResults[name].at(
i);
531 inline std::vector<errno_result>
get_errno(
const std::string& name) {
532 return errnoResults[name];
538 return errnoResults[name].at(
i);
543 inline std::vector<exception_result>
get_exception(
const std::string& name) {
544 return exceptionResults[name];
550 return exceptionResults[name].at(
i);
562 int argc = 0,
const char**
argv =
nullptr) {
Error checking context, for assertions and exception checking.
Definition err.h:90
void errno_value(const std::string &name, Function f, InputType x, int expected_errno, bool quiet=false)
Check errno value after function call.
Definition err.h:305
void errno_flags(const std::string &name, Function f, InputType x, std::vector< int > &expected_flags, bool quiet=false)
Check the value of errno after a function call, comparing to multiple expected flags which should all...
Definition err.h:356
std::vector< errno_result > get_errno(const std::string &name)
Get the results of errno checking by name or label.
Definition err.h:531
err_context(std::string moduleName, int argc=0, const char **argv=nullptr)
Setup the error checking module.
Definition err.h:259
~err_context()
Terminate the error checking module.
Definition err.h:269
void setup(const std::string &moduleName, int argc=0, const char **argv=nullptr)
Setup error checking module.
Definition err.h:125
std::shared_ptr< random::random_context > random
Random module settings for the context, dynamically allocated and possibly shared between multiple co...
Definition err.h:116
std::vector< assert_result > get_assertion(const std::string &name)
Get the results of an assertion by name or label.
Definition err.h:519
errno_result get_errno(const std::string &name, unsigned int i)
Get a single result of errno checking by label and index.
Definition err.h:537
assert_result get_assertion(const std::string &name, unsigned int i)
Get a single result of an assertion by label and index.
Definition err.h:525
std::vector< exception_result > get_exception(const std::string &name)
Get the results of exception checking by name or label.
Definition err.h:543
void errno_flags(const std::string &name, Function f, std::function< InputType()> generator, std::vector< int > &expected_flags, bool quiet=false)
Check the value of errno after a function call, comparing to multiple expected flags which should all...
Definition err.h:395
err_settings settings
Settings for the benchmark context.
Definition err.h:108
std::shared_ptr< output::output_context > output
Output module settings for the context, dynamically allocated and possibly shared between multiple co...
Definition err.h:112
exception_result get_exception(const std::string &name, unsigned int i)
Get a single result of exception checking by label and index.
Definition err.h:549
void errno_value(const std::string &name, Function f, std::function< InputType()> generator, int expected_errno, bool quiet=false)
Check errno value after function call.
Definition err.h:337
void terminate(bool exit=false)
Terminate the error testing environment.
Definition err.h:150
void assert(const std::string &name, bool exp, std::string description="", bool quiet=false)
Assert that an expression is true.
Definition err.h:280
Common definitions for the framework.
Structures for the error checking module.
err_context make_context(const std::string &moduleName, int argc=0, const char **argv=nullptr)
Construct an error checking context with the given parameters.
Definition err.h:561
General namespace of the framework.
Definition benchmark.h:22
constexpr FloatType get_nan()
Get a quiet NaN of the specified floating point type.
Definition common.h:65
The output module, with formatting capabilities.
The pseudorandom number generation and sampling module.
Result of assertion checking of a function.
Definition err_structures.h:21
std::string name
Identifying name of the function or test case.
Definition err_structures.h:24
Settings of the error testing module, used in err_context.
Definition err.h:39
std::vector< std::string > outputFiles
The files to write all error checking results to.
Definition err.h:48
std::vector< std::string > assertOutputFiles
The files to write assertion results results to (if empty, all results are output to a generic file).
Definition err.h:52
std::vector< std::string > exceptionOutputFiles
The files to write exception results results to (if empty, all results are output to a generic file).
Definition err.h:70
std::vector< std::string > assertColumns
Default columns to print for assertions.
Definition err.h:55
std::vector< std::string > exceptionColumns
Default columns to print for exception checks.
Definition err.h:73
std::map< std::string, bool > pickedChecks
Target checks marked for execution, can be picked by passing test case names by command line.
Definition err.h:80
std::string moduleName
Name of the module being tested.
Definition err.h:42
std::vector< std::string > errnoOutputFiles
The files to write errno checking results to (if empty, all results are output to a generic file).
Definition err.h:61
std::vector< std::string > errnoColumns
Default columns to print for errno checks.
Definition err.h:64
bool quiet
Whether to print to standard output.
Definition err.h:83
bool outputToFile
Whether to print to an output file.
Definition err.h:45
Result of errno checking of a function.
Definition err_structures.h:42
Result of exception checking of a function.
Definition err_structures.h:63