ZeroErr
zeroerr Namespace Reference

Namespaces

 detail
 
 details
 

Classes

struct  BenchState
 
struct  ColorInit
 
struct  DataBlock
 
class  FileLogger
 
struct  FileCache
 
class  DirectoryLogger
 
class  OStreamLogger
 
struct  StyleManager
 
struct  Filters
 
class  ConsoleReporter
 
class  XmlReporter
 
struct  assert_info
 This is a one-byte assert info struct, which is used to collect the meta info of an assertion. More...
 
struct  AssertionData
 AssertionData is a struct that contains all the information of an assertion. It will be thrown as an exception when the assertion failed. More...
 
struct  PerfCountSet
 PerfCountSet is a set of performance counters. More...
 
struct  PerformanceCounter
 PerformanceCounter is a class to measure the performance of a function. More...
 
struct  BenchResult
 BenchResult is a result of running the benchmark. More...
 
struct  Benchmark
 Benchmark create a core object for configuration of a benchmark. This class is a driver to run multiple times of a benchmark. Each time of a run will generate a row of data. Report will print the data in console. More...
 
struct  last
 
struct  last< T1 >
 
class  AggregateOf
 
class  Arbitrary
 
class  Arbitrary< bool >
 
class  Arbitrary< T, is_unsigned_int< T > >
 
class  Arbitrary< T, is_signed_int< T > >
 
class  Arbitrary< T, is_float_point< T > >
 
class  Arbitrary< T, is_string< T > >
 
class  Arbitrary< T, is_modifable< T > >
 
class  Arbitrary< std::pair< T, U > >
 
class  Arbitrary< std::tuple< T... > >
 
class  Arbitrary< const T >
 
struct  ContainerOfBase
 
class  AssociativeContainerOf
 
class  SequenceContainerOf
 
class  Domain
 Domain class for generating random values of a specific type. More...
 
class  DomainConvertable
 
class  ElementOf
 
class  InRange
 
struct  FuzzTest
 FuzzTest is a template class to create a fuzz test for the target function. More...
 
struct  FuzzTestWithDomain
 FuzzTestWithDomain implements the Base class with the domain passed into. More...
 
struct  IFuzzTest
 
class  FuzzFinishedException
 
struct  TerminalSize
 
struct  deferred_false
 
struct  ExprResult
 
struct  Expression
 
struct  ExpressionDecomposer
 
class  IMatcher
 
class  IMatcherRef
 
class  CombinedMatcher
 
class  NotMatcher
 
struct  StartWithMatcher
 
class  Rng
 
struct  IRObject
 
struct  LogInfo
 LogInfo is a struct to store the meta data of the log message. More...
 
struct  LogMessage
 LogMessage is a class to store the log message. More...
 
struct  LogMessageImpl
 LogMessageImpl is the implementation of the LogMessage. More...
 
class  Logger
 
struct  PushResult
 
class  LogIterator
 LogIterator is a class to iterate the log messages. More...
 
class  LogStream
 LogStream is a class to manage the log messages. More...
 
class  IContextScope
 ContextScope is a helper class created in each basic block where you use INFO(). The context scope can has lazy evaluated function F(std::ostream&) that is called when the assertation is failed. More...
 
class  ContextScope
 
struct  rank
 rank is a helper class for Printer to define the priority of overloaded functions. More...
 
struct  rank< 0 >
 
struct  Printer
 A functor class Printer for printing a value of any type. More...
 
struct  Card
 Card defines a display range in the console. More...
 
class  Table
 Table is used to generate a table with configurable style. More...
 
class  TestContext
 TestContext is a class that holds the test results and reporter context. There are 8 different matrices that are used to store the test results. More...
 
struct  UnitTest
 UnitTest is a class that holds the test configuration. There are several options that can be set to configure the test. More...
 
struct  TestCase
 TestCase is a class that holds the test case information. There are several fields that are used to store the test case information. More...
 
struct  SubCase
 SubCase is a class that holds the subcase information. More...
 
struct  TestedObjects
 
class  IReporter
 IReporter is an interface that is used to report the test results. You can create a new reporter by inheriting this class and implementing the virtual functions. The following events will be called once it happens during testing. More...
 
class  CombinationalTest
 CombinationalTest is a class that is used to cross test a few lists of arguments. One example. More...
 
class  TestArgs
 TestArgs is a class that is used to store the test arguments. More...
 

Typedefs

using Clock = std::conditional< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock >::type
 
template<typename T >
using is_unsigned_int = typename std::enable_if< std::is_integral< T >::value &&!std::numeric_limits< T >::is_signed, void >::type
 
template<typename T >
using is_signed_int = typename std::enable_if< std::is_integral< T >::value &&std::numeric_limits< T >::is_signed, void >::type
 
template<typename T >
using is_float_point = typename std::enable_if< std::is_floating_point< T >::value, void >::type
 
template<typename T >
using is_string = typename std::enable_if< detail::is_specialization< T, std::basic_string >::value >::type
 
template<typename T >
using is_modifable = typename std::enable_if<!detail::is_specialization< T, std::basic_string >::value, decltype(T().begin(), T().end(), T().size(), T().insert(T().end(), std::declval< typename T::value_type >()), T().erase(T().begin()),(void) 0)>::type
 
typedef std::string(* LogCustomCallback) (const LogMessage &, bool colorful)
 

Enumerations

enum class  assert_level : uint8_t { ZEROERR_WARN_l , ZEROERR_ERROR_l , ZEROERR_FATAL_l }
 
enum class  assert_throw : uint8_t { no_throw , throws , throws_as }
 
enum class  assert_cmp : uint8_t {
  eq , ne , gt , ge ,
  lt , le
}
 
enum  OutputStream { STDOUT , STDERR }
 
enum  LogSeverity {
  INFO_l , LOG_l , WARN_l , ERROR_l ,
  FATAL_l
}
 
enum  TestType { test_case = 1 , sub_case = 1 << 1 , bench = 1 << 2 , fuzz_test = 1 << 3 }
 TestType is a enum describe the type of the test case. More...
 

Functions

Clock::duration calcClockResolution (size_t numEvaluations) noexcept
 
Clock::duration clockResolution () noexcept
 
BenchStatecreateBenchState (Benchmark &benchmark)
 
void destroyBenchState (BenchState *state)
 
size_t getNumIter (BenchState *state)
 
void runIteration (BenchState *state)
 
void moveResult (BenchState *state, std::string name)
 
 ZEROERR_MUTEX (m)
 
void disableColorOutput ()
 Global function to disable colorful output. More...
 
void enableColorOutput ()
 Global function to enable colorful output. More...
 
void RunFuzzTest (IFuzzTest &fuzz_test, int seed, int runs, int max_len, int timeout, int len_control)
 
void setLogCustomCallback (LogCustomCallback callback)
 set the log custom callback, this can support custom format of the log message More...
 
void setLogLevel (LogSeverity level)
 set the log level More...
 
void setLogCategory (const char *categories)
 set the log category More...
 
void suspendLog ()
 suspend the log to flush to the file More...
 
void resumeLog ()
 resume the log to flush to the file More...
 
PrintergetStdoutPrinter ()
 
PrintergetStderrPrinter ()
 
std::string _rept (unsigned k, std::string j, Table::Style &)
 
template<typename Arg >
void doNotOptimizeAway (Arg &&arg)
 Makes sure none of the given arguments are optimized away by the compiler. More...
 
template<typename... Args>
auto get_last (Args &&... args) -> typename last< Args... >::type
 get_last is a function to get the last argument of a variadic template. It is used by DebugExpr. More...
 
template<typename... T>
auto DebugExpr (const char *file, unsigned line, const char *func, const char *exprs, T... t) -> typename last< T... >::type
 DebugExpr is a function to print any type of variable with its type name. It is used by dbg macro. More...
 
template<typename... Inner>
AggregateOf< std::tuple< typename Inner::ValueType... >, Inner... > TupleOf (Inner &&... inner)
 
template<typename K , typename V >
AggregateOf< std::pair< typename K::ValueType, typename V::ValueType >, K, V > PairOf (K &&k, V &&v)
 
template<typename T , typename Inner >
std::enable_if< detail::is_associative_container< T >::value, AssociativeContainerOf< T, Inner > >::type ContainerOf (Inner &&inner)
 
template<typename T , typename Inner >
std::enable_if<!detail::is_associative_container< T >::value &&detail::is_container< T >::value, SequenceContainerOf< T, Inner > >::type ContainerOf (Inner &&inner)
 
template<template< typename, typename... > class T, typename... Inner, typename C = T<typename Inner::ValueType...>>
auto ContainerOf (Inner... inner) -> decltype(ContainerOf< C >(std::move(inner)...))
 
template<typename... T>
std::string format (const char *fmt, T... args)
 Format a string with arguments. More...
 
template<typename T >
FuzzTest< T > FuzzFunction (T func, TestContext *context)
 
template<typename T >
std::vector< T > ReadCorpusFromDir (std::string dir)
 
bool isTerminalOutput (OutputStream stream)
 
TerminalSize getTerminalSize ()
 
template<typename T >
std::enable_if< std::is_constructible< std::string, T >::value, IMatcherRef< std::string > >::type start_with (T &&s)
 
template<typename... T>
PushResult log (T &&... args)
 
template<typename... T>
PushResult log (LogStream &stream, T &&... args)
 
template<typename F >
ContextScope< F > MakeContextScope (const F &f)
 
template<typename T >
void PrinterExt (Printer &P, T v, unsigned level, const char *lb, rank< 0 >)
 PrinterExt is an extension of Printer that allows user to write custom rules for printing. More...
 

Variables

const char * Reset = _Reset
 
const char * Bright = _Bright
 
const char * Dim = _Dim
 
const char * Underscore = _Underscore
 
const char * Blink = _Blink
 
const char * Reverse = _Reverse
 
const char * Hidden = _Hidden
 
const char * FgBlack = _FgBlack
 
const char * FgRed = _FgRed
 
const char * FgGreen = _FgGreen
 
const char * FgYellow = _FgYellow
 
const char * FgBlue = _FgBlue
 
const char * FgMagenta = _FgMagenta
 
const char * FgCyan = _FgCyan
 
const char * FgWhite = _FgWhite
 
const char * BgBlack = _BgBlack
 
const char * BgRed = _BgRed
 
const char * BgGreen = _BgGreen
 
const char * BgYellow = _BgYellow
 
const char * BgBlue = _BgBlue
 
const char * BgMagenta = _BgMagenta
 
const char * BgCyan = _BgCyan
 
const char * BgWhite = _BgWhite
 
int _ZEROERR_G_VERBOSE = 0
 
thread_local std::vector< IContextScope * > _ZEROERR_G_CONTEXT_SCOPE_VECTOR
 
constexpr size_t LogStreamMaxSize = 1 * 1024 - 16
 
constexpr unsigned max_rank = 5
 

Typedef Documentation

◆ Clock

using zeroerr::Clock = typedef std::conditional<std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock>::type

◆ is_float_point

template<typename T >
using zeroerr::is_float_point = typedef typename std::enable_if<std::is_floating_point<T>::value, void>::type

◆ is_modifable

template<typename T >
using zeroerr::is_modifable = typedef typename std::enable_if<!detail::is_specialization<T, std::basic_string>::value, decltype( T().begin(), T().end(), T().size(), T().insert(T().end(), std::declval<typename T::value_type>()), T().erase(T().begin()), (void)0)>::type

◆ is_signed_int

template<typename T >
using zeroerr::is_signed_int = typedef typename std::enable_if<std::is_integral<T>::value && std::numeric_limits<T>::is_signed, void>::type

◆ is_string

template<typename T >
using zeroerr::is_string = typedef typename std::enable_if<detail::is_specialization<T, std::basic_string>::value>::type

◆ is_unsigned_int

template<typename T >
using zeroerr::is_unsigned_int = typedef typename std::enable_if<std::is_integral<T>::value && !std::numeric_limits<T>::is_signed, void>::type

◆ LogCustomCallback

typedef std::string(* zeroerr::LogCustomCallback) (const LogMessage &, bool colorful)

Enumeration Type Documentation

◆ assert_cmp

enum zeroerr::assert_cmp : uint8_t
strong
Enumerator
eq 
ne 
gt 
ge 
lt 
le 

◆ assert_level

enum zeroerr::assert_level : uint8_t
strong
Enumerator
ZEROERR_WARN_l 
ZEROERR_ERROR_l 
ZEROERR_FATAL_l 

◆ assert_throw

enum zeroerr::assert_throw : uint8_t
strong
Enumerator
no_throw 
throws 
throws_as 

◆ LogSeverity

Enumerator
INFO_l 
LOG_l 
WARN_l 
ERROR_l 
FATAL_l 

◆ OutputStream

Enumerator
STDOUT 
STDERR 

◆ TestType

TestType is a enum describe the type of the test case.

Enumerator
test_case 
sub_case 
bench 
fuzz_test 

Function Documentation

◆ _rept()

std::string zeroerr::_rept ( unsigned  k,
std::string  j,
Table::Style  
)
inline

◆ calcClockResolution()

Clock::duration zeroerr::calcClockResolution ( size_t  numEvaluations)
noexcept

◆ clockResolution()

Clock::duration zeroerr::clockResolution ( )
noexcept

◆ ContainerOf() [1/3]

template<typename T , typename Inner >
std::enable_if<detail::is_associative_container<T>::value, AssociativeContainerOf<T, Inner> >::type zeroerr::ContainerOf ( Inner &&  inner)

◆ ContainerOf() [2/3]

template<typename T , typename Inner >
std::enable_if<!detail::is_associative_container<T>::value && detail::is_container<T>::value, SequenceContainerOf<T, Inner> >::type zeroerr::ContainerOf ( Inner &&  inner)

◆ ContainerOf() [3/3]

template<template< typename, typename... > class T, typename... Inner, typename C = T<typename Inner::ValueType...>>
auto zeroerr::ContainerOf ( Inner...  inner) -> decltype(ContainerOf<C>(std::move(inner)...))

◆ createBenchState()

BenchState * zeroerr::createBenchState ( Benchmark benchmark)

◆ DebugExpr()

template<typename... T>
auto zeroerr::DebugExpr ( const char *  file,
unsigned  line,
const char *  func,
const char *  exprs,
T...  t 
) -> typename last<T...>::type

DebugExpr is a function to print any type of variable with its type name. It is used by dbg macro.

◆ destroyBenchState()

void zeroerr::destroyBenchState ( BenchState state)

◆ disableColorOutput()

void zeroerr::disableColorOutput ( )

Global function to disable colorful output.

◆ doNotOptimizeAway()

template<typename Arg >
void zeroerr::doNotOptimizeAway ( Arg &&  arg)

Makes sure none of the given arguments are optimized away by the compiler.

Template Parameters
ArgType of the argument that shouldn't be optimized away.
Parameters
argThe input that we mark as being used, even though we don't do anything with it.

◆ enableColorOutput()

void zeroerr::enableColorOutput ( )

Global function to enable colorful output.

◆ format()

template<typename... T>
std::string zeroerr::format ( const char *  fmt,
T...  args 
)

Format a string with arguments.

Parameters
fmtThe format string
argsThe arguments
Returns
std::string The formatted string

This function is used to format a string with arguments. The format string is a string with placeholders in the form of {}. You can pass any type of arguments to this function and it will format the string accordingly.

Example: format("Hello, {name}!", "John") -> "Hello, John!"

◆ FuzzFunction()

template<typename T >
FuzzTest<T> zeroerr::FuzzFunction ( func,
TestContext context 
)

◆ get_last()

template<typename... Args>
auto zeroerr::get_last ( Args &&...  args) -> typename last<Args...>::type

get_last is a function to get the last argument of a variadic template. It is used by DebugExpr.

◆ getNumIter()

size_t zeroerr::getNumIter ( BenchState state)

◆ getStderrPrinter()

Printer & zeroerr::getStderrPrinter ( )

◆ getStdoutPrinter()

Printer & zeroerr::getStdoutPrinter ( )

◆ getTerminalSize()

TerminalSize zeroerr::getTerminalSize ( )

◆ isTerminalOutput()

bool zeroerr::isTerminalOutput ( OutputStream  stream)

◆ log() [1/2]

template<typename... T>
PushResult zeroerr::log ( LogStream stream,
T &&...  args 
)

◆ log() [2/2]

template<typename... T>
PushResult zeroerr::log ( T &&...  args)

◆ MakeContextScope()

template<typename F >
ContextScope<F> zeroerr::MakeContextScope ( const F &  f)

◆ moveResult()

void zeroerr::moveResult ( BenchState state,
std::string  name 
)

◆ PairOf()

template<typename K , typename V >
AggregateOf<std::pair<typename K::ValueType, typename V::ValueType>, K, V> zeroerr::PairOf ( K &&  k,
V &&  v 
)

◆ PrinterExt()

template<typename T >
void zeroerr::PrinterExt ( Printer P,
v,
unsigned  level,
const char *  lb,
rank< 0 >   
)

PrinterExt is an extension of Printer that allows user to write custom rules for printing.

User can use SFINAE to extend PrinterExt, e.g.:

template<typename T>
typename std::enable_if<std::is_base_of<llvm::Function, T>::value, void>::type
PrinterExt(Printer& P, T* s, unsigned level, const char* lb, rank<3>);
void PrinterExt(Printer &, T, unsigned, const char *, rank< 0 >)
PrinterExt is an extension of Printer that allows user to write custom rules for printing.
Definition: print.h:300
Template Parameters
Tthe type of the object to be printed.
Parameters
PPrinter class
vthe object to be printed.
levelthe indentation level.
lbthe line break.
rthe rank of the rule. 0 is lowest priority.

◆ ReadCorpusFromDir()

template<typename T >
std::vector<T> zeroerr::ReadCorpusFromDir ( std::string  dir)

◆ resumeLog()

void zeroerr::resumeLog ( )

resume the log to flush to the file

◆ RunFuzzTest()

void zeroerr::RunFuzzTest ( IFuzzTest fuzz_test,
int  seed,
int  runs,
int  max_len,
int  timeout,
int  len_control 
)

◆ runIteration()

void zeroerr::runIteration ( BenchState state)

◆ setLogCategory()

void zeroerr::setLogCategory ( const char *  categories)

set the log category

◆ setLogCustomCallback()

void zeroerr::setLogCustomCallback ( LogCustomCallback  callback)

set the log custom callback, this can support custom format of the log message

◆ setLogLevel()

void zeroerr::setLogLevel ( LogSeverity  level)

set the log level

◆ start_with()

template<typename T >
std::enable_if<std::is_constructible<std::string, T>::value, IMatcherRef<std::string> >::type zeroerr::start_with ( T &&  s)

◆ suspendLog()

void zeroerr::suspendLog ( )

suspend the log to flush to the file

◆ TupleOf()

template<typename... Inner>
AggregateOf<std::tuple<typename Inner::ValueType...>, Inner...> zeroerr::TupleOf ( Inner &&...  inner)

◆ ZEROERR_MUTEX()

zeroerr::ZEROERR_MUTEX ( )

Variable Documentation

◆ _ZEROERR_G_CONTEXT_SCOPE_VECTOR

thread_local std::vector< IContextScope * > zeroerr::_ZEROERR_G_CONTEXT_SCOPE_VECTOR

◆ _ZEROERR_G_VERBOSE

int zeroerr::_ZEROERR_G_VERBOSE = 0

◆ BgBlack

const char * zeroerr::BgBlack = _BgBlack

◆ BgBlue

const char * zeroerr::BgBlue = _BgBlue

◆ BgCyan

const char * zeroerr::BgCyan = _BgCyan

◆ BgGreen

const char * zeroerr::BgGreen = _BgGreen

◆ BgMagenta

const char * zeroerr::BgMagenta = _BgMagenta

◆ BgRed

const char * zeroerr::BgRed = _BgRed

◆ BgWhite

const char * zeroerr::BgWhite = _BgWhite

◆ BgYellow

const char * zeroerr::BgYellow = _BgYellow

◆ Blink

const char * zeroerr::Blink = _Blink

◆ Bright

const char * zeroerr::Bright = _Bright

◆ Dim

const char * zeroerr::Dim = _Dim

◆ FgBlack

const char * zeroerr::FgBlack = _FgBlack

◆ FgBlue

const char * zeroerr::FgBlue = _FgBlue

◆ FgCyan

const char * zeroerr::FgCyan = _FgCyan

◆ FgGreen

const char * zeroerr::FgGreen = _FgGreen

◆ FgMagenta

const char * zeroerr::FgMagenta = _FgMagenta

◆ FgRed

const char * zeroerr::FgRed = _FgRed

◆ FgWhite

const char * zeroerr::FgWhite = _FgWhite

◆ FgYellow

const char * zeroerr::FgYellow = _FgYellow

◆ Hidden

const char * zeroerr::Hidden = _Hidden

◆ LogStreamMaxSize

constexpr size_t zeroerr::LogStreamMaxSize = 1 * 1024 - 16
constexpr

◆ max_rank

constexpr unsigned zeroerr::max_rank = 5
constexpr

◆ Reset

const char * zeroerr::Reset = _Reset

◆ Reverse

const char * zeroerr::Reverse = _Reverse

◆ Underscore

const char * zeroerr::Underscore = _Underscore