Chebyshev
Unit testing for scientific software
Loading...
Searching...
No Matches
chebyshev::output::output_context Class Reference

module context. More...

Public Member 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.
 
 output_context ()
 Default constructor for the output module.
 
 ~output_context ()
 Destructor which automatically terminates the module.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
bool open_file (const std::string &filename)
 Try to open a new output file, returning whether it was correctly opened.
 
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.
 
void log (const std::string &message, LogLevel level)
 Log a message to standard output according to the set log level.
 
void debug (const std::string &message)
 Write debug information to standard output according to the set log level.
 
void info (const std::string &message)
 Write runtime information to standard output according to the set log level.
 
void warn (const std::string &message)
 Write a warning to standard output according to the set log level.
 
void error (const std::string &message)
 Write an error message to standard error according to the set log level.
 

Public Attributes

output_settings settings
 Settings for the output module.
 

Detailed Description

module context.

Member Function Documentation

◆ debug()

void chebyshev::output::output_context::debug ( const std::string &  message)
inline

Write debug information to standard output according to the set log level.

Parameters
messageThe debug message to write

◆ error()

void chebyshev::output::output_context::error ( const std::string &  message)
inline

Write an error message to standard error according to the set log level.

Parameters
messageThe error message to write

◆ generate_table()

template<typename ResultType >
auto chebyshev::output::output_context::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.

◆ info()

void chebyshev::output::output_context::info ( const std::string &  message)
inline

Write runtime information to standard output according to the set log level.

Parameters
messageThe information message to write

◆ log()

void chebyshev::output::output_context::log ( const std::string &  message,
LogLevel  level 
)
inline

Log a message to standard output according to the set log level.

Parameters
messageThe message to log
levelThe log level of the message

◆ open_file()

bool chebyshev::output::output_context::open_file ( const 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::output_context::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.

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::output_context::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::output_context::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::output_context::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::output_context::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::output_context::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

◆ warn()

void chebyshev::output::output_context::warn ( const std::string &  message)
inline

Write a warning to standard output according to the set log level.

Parameters
messageThe warning message to write

The documentation for this class was generated from the following file: