Chebyshev
Unit testing for scientific software
chebyshev::output Namespace Reference

Functions to manage printing results. More...

Namespaces

 format
 Output formatting functions.
 

Classes

class  field_options
 Custom options for printing a certain field. More...
 
class  output_settings
 Global settings of printing results to standard output. More...
 

Typedefs

using OutputFormat = output_settings::OutputFormat_t
 A function which converts the table entries of a row to a string to print (e.g. More...
 

Functions

void setup ()
 Setup printing to the output stream with default options.
 
void terminate ()
 Terminate the output module by closing all output files and resetting its settings.
 
std::string resolve_field (const std::string &fieldName, prec::estimate_result r)
 Resolve the field of an estimate result by name, returning the value as a string. More...
 
std::string resolve_field (const std::string &fieldName, prec::equation_result r)
 Resolve the field of an equation result by name, returning the value as a string. More...
 
std::string resolve_field (const std::string &fieldName, benchmark::benchmark_result r)
 Resolve the field of a benchmark result by name, returning the value as a string.
 
std::string resolve_field (const std::string &fieldName, err::assert_result r)
 Resolve the field of an assertion result by name, returning the value as a string. More...
 
std::string resolve_field (const std::string &fieldName, err::errno_result r)
 Resolve the field of an errno checking result by name, returning the value as a string. More...
 
std::string resolve_field (const std::string &fieldName, err::exception_result r)
 Resolve the field of an exception checking result by name, returning the value as a string. More...
 
template<typename ResultType >
auto generate_table (const std::map< std::string, std::vector< ResultType >> &results, const std::vector< std::string > &fields)
 Generate a table of results as a string matrix to pass to a specific formatter of OutputFormat type. More...
 
bool open_file (std::string filename)
 Try to open a new output file, returning whether it was correctly opened. More...
 
template<typename ResultType >
void print_results (const std::map< std::string, std::vector< ResultType >> &results, const std::vector< std::string > &fields, const std::vector< std::string > &filenames)
 Print the test results to standard output and output files with their given formats, defaulting to settings.outputFiles if no filenames are specified. More...
 

Variables

struct chebyshev::output::output_settings settings
 

Detailed Description

Functions to manage printing results.

Typedef Documentation

◆ OutputFormat

using chebyshev::output::OutputFormat = typedef output_settings::OutputFormat_t

A function which converts the table entries of a row to a string to print (e.g.

adding separators and padding).

See also
output_settings::OutputFormat_t

Function Documentation

◆ generate_table()

template<typename ResultType >
auto chebyshev::output::generate_table ( const std::map< std::string, std::vector< ResultType >> &  results,
const std::vector< std::string > &  fields 
)
inline

Generate a table of results as a string matrix to pass to a specific formatter of OutputFormat type.

This function is used by print_results to create the table of results which is then formatted and printed to output.

Parameters
resultsThe map of test results of any type
fieldsThe fields of the test results to write to each column, in order.
Returns
A string matrix representing the results as a table.

◆ open_file()

bool chebyshev::output::open_file ( std::string  filename)
inline

Try to open a new output file, returning whether it was correctly opened.

This function is called internally and is generally not needed, you can just specify the filenames and the module will open them when needed.

Parameters
filenameThe name of the file
Returns
Whether the file was correctly opened or not

◆ print_results()

template<typename ResultType >
void chebyshev::output::print_results ( const std::map< std::string, std::vector< ResultType >> &  results,
const std::vector< std::string > &  fields,
const std::vector< std::string > &  filenames 
)
inline

Print the test results to standard output and output files with their given formats, defaulting to settings.outputFiles if no filenames are specified.

Parameters
resultsThe map of test results, of any type
fieldsThe fields of the test results to write, in order
filenamesThe names of the module specific output files

◆ resolve_field() [1/5]

std::string chebyshev::output::resolve_field ( const std::string &  fieldName,
err::assert_result  r 
)
inline

Resolve the field of an assertion result by name, returning the value as a string.

Parameters
fieldNameThe name of the field to resolve
rThe assertion result to read the fields of

◆ resolve_field() [2/5]

std::string chebyshev::output::resolve_field ( const std::string &  fieldName,
err::errno_result  r 
)
inline

Resolve the field of an errno checking result by name, returning the value as a string.

Parameters
fieldNameThe name of the field to resolve
rThe errno checking result to read the fields of

◆ resolve_field() [3/5]

std::string chebyshev::output::resolve_field ( const std::string &  fieldName,
err::exception_result  r 
)
inline

Resolve the field of an exception checking result by name, returning the value as a string.

Parameters
fieldNameThe name of the field to resolve
rThe exception checking result to read the fields of

◆ resolve_field() [4/5]

std::string chebyshev::output::resolve_field ( const std::string &  fieldName,
prec::equation_result  r 
)
inline

Resolve the field of an equation result by name, returning the value as a string.

Parameters
fieldNameThe name of the field to resolve
rThe equation result to read the fields of

◆ resolve_field() [5/5]

std::string chebyshev::output::resolve_field ( const std::string &  fieldName,
prec::estimate_result  r 
)
inline

Resolve the field of an estimate result by name, returning the value as a string.

Parameters
fieldNameThe name of the field to resolve
rThe estimate result to read the fields of