Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/test/event-log.hpp"
Helper to log and verify the occurrence of events.
The EventLog object is a front-end handle, logging flexible information records into a possibly shared (vector) buffer in heap storage. An extended query DSL allows to write assertions to cover the occurrence of events in unit tests.
Definition at line 275 of file event-log.hpp.
Public Types | |
using | ArgSeq = lib::diff::RecordSetup< string >::Storage |
typedef Iter | const_iterator |
using | Iter = lib::RangeIter< Log::const_iterator > |
typedef const Entry | value_type |
Public Member Functions | |
EventLog (string logID) | |
EventLog (const char *logID) | |
template<class X > | |
EventLog (const X *const obj) | |
template<typename X , typename... ARGS> | |
EventLog & | addAttrib (string const &key, X &&initialiser, ARGS &&...args) |
Qualify the latest entry: set further attribute(s) | |
const_iterator | begin () const |
EventLog & | call (string target, string function) |
Log occurrence of a function call with no arguments. More... | |
EventLog & | call (string target, string function, ArgSeq &&args) |
Log a function call with a sequence of stringified arguments. | |
EventLog & | call (const char *target, const char *function, ArgSeq &&args) |
template<typename... ARGS> | |
EventLog & | call (string target, string function, ARGS const &...args) |
Log a function call with arbitrary arguments. | |
template<class X , typename... ARGS> | |
EventLog & | call (const X *const targetObj, string function, ARGS const &...args) |
Log a function call on given object ("`this`")... More... | |
template<typename... ARGS> | |
EventLog & | call (const char *target, string function, ARGS const &...args) |
EventLog & | clear () |
purge log contents while retaining just the original Header-ID | |
EventLog & | clear (string alteredLogID) |
purge log contents and also reset Header-ID More... | |
EventLog & | clear (const char *alteredLogID) |
template<class X > | |
EventLog & | clear (const X *const obj) |
EventLog & | create (string text) |
Log the creation of an object. More... | |
EventLog & | destroy (string text) |
Log the destruction of an object. More... | |
bool | empty () const |
const_iterator | end () const |
EventMatch | ensureNot (string match) const |
start a query to ensure the given expression does not match. More... | |
EventLog & | error (string text) |
Log an error note. | |
EventLog & | event (string text) |
log some text as event | |
EventLog & | event (string classifier, string text) |
log some event, with additional ID or classifier More... | |
template<typename... ELMS> | |
EventLog & | event (string classifier, ELMS const &...initialiser) |
EventLog & | fatal (string text) |
Log a fatal failure. | |
string | getID () const |
EventLog & | joinInto (EventLog &otherLog) |
Merge this log into another log, forming a combined log. More... | |
template<typename... ELMS> | |
EventLog & | note (ELMS const &...initialiser) |
EventMatch | verify (string match) const |
start a query to match for some substring. More... | |
EventMatch | verifyCall (string match) const |
start a query to match especially a function call More... | |
EventMatch | verifyEvent (string match) const |
start a query to match for some event. More... | |
EventMatch | verifyEvent (string classifier, string match) const |
start a query to match for an specific kind of element More... | |
template<typename X > | |
EventMatch | verifyEvent (string classifier, X const &something) const |
EventMatch | verifyMatch (string regExp) const |
start a query to match with a regular expression More... | |
EventLog & | warn (string text) |
Log a warning entry. | |
Friends | |
const_iterator | begin (EventLog const &log) |
const_iterator | end (EventLog const &log) |
bool | operator!= (EventLog const &l1, EventLog const &l2) |
bool | operator== (EventLog const &l1, EventLog const &l2) |
equality comparison is based on the actual log contents | |
Private Member Functions | |
void | log (std::initializer_list< string > const &ili) |
template<typename ATTR , typename ARGS > | |
void | log (Symbol typeID, ATTR &&attribs, ARGS &&args) |
Private Attributes | |
std::shared_ptr< Log > | log_ |
|
inline |
Definition at line 317 of file event-log.hpp.
References lib::idi::instanceTypeID().
Referenced by ActivityDetector::DiagnosticFun< RET, ARGS >::operator()().
Merge this log into another log, forming a combined log.
otherLog | target to integrate this log's contents into. |
joinInto
operation both integrates this logs contents into the other log, and then disconnects from the old storage and connects to the storage of the combined log. joinInto
in such a situation, only the current EventLog front-end handle will be rewritten to point to the combined log, while any other clone will continue to point to the original log storage. Definition at line 625 of file event-log.cpp.
Referenced by EventLog_test::verify_logJoining(), and MockElm::verifyMark().
EventLog & clear | ( | string | alteredLogID | ) |
purge log contents and also reset Header-ID
Definition at line 658 of file event-log.cpp.
EventLog & event | ( | string | classifier, |
string | text | ||
) |
log some event, with additional ID or classifier
classifier | info to be saved into the ID attribute |
text | actual payload info, to be logged as argument |
Definition at line 683 of file event-log.cpp.
EventLog & call | ( | string | target, |
string | function | ||
) |
Log occurrence of a function call with no arguments.
target | the object or scope on which the function is invoked |
function | name of the function being invoked |
Definition at line 690 of file event-log.cpp.
Referenced by MockElm::buildMutator(), TrackingFactory::create(), TrackingFactory::dispose(), MockElm::doExpand(), MockElm::doMark(), MockElm::doReveal(), MockElm::kill(), PlaceholderCommand< ARGS >::operate(), ActivityDetector::DiagnosticFun< RET, ARGS >::operator()(), and MockElm::~MockElm().
Log a function call on given object ("`this`")...
Definition at line 388 of file event-log.hpp.
References lib::idi::instanceTypeID().
EventLog & create | ( | string | text | ) |
Log the creation of an object.
Such an entry can be matched as event
Definition at line 733 of file event-log.cpp.
Referenced by MockElm::buildMutator().
EventLog & destroy | ( | string | text | ) |
Log the destruction of an object.
Can be matched as event.
Definition at line 740 of file event-log.cpp.
Referenced by MockElm::kill(), and MockElm::~MockElm().
EventMatch verify | ( | string | match | ) | const |
start a query to match for some substring.
The resulting matcher object will qualify on any log entry containing the given string. By adding subsequent further query expressions on the returned matcher object, the query can be refined. Moreover it is possible to chain up further search queries, which will be executing starting from the position of the previous match. The final result can be retrieved by bool
conversion
Definition at line 752 of file event-log.cpp.
References EventMatch::locate().
Referenced by BusTerm_test::attachNewBusTerm(), EventLog_test::verify_logJoining(), and MockElm::verifyMark().
EventMatch verifyMatch | ( | string | regExp | ) | const |
start a query to match with a regular expression
regExp | definition |
string
representation of the log entries. Meaning, it can also match type and attributes Definition at line 761 of file event-log.cpp.
References EventMatch::locateMatch().
Referenced by Nexus::wasBound(), and Nexus::wasInvoked().
EventMatch verifyEvent | ( | string | match | ) | const |
start a query to match for some event.
match | text to (substring)match against the argument logged as event |
Definition at line 770 of file event-log.cpp.
References EventMatch::locateEvent().
Referenced by MockElm::verifyMark().
EventMatch verifyEvent | ( | string | classifier, |
string | match | ||
) | const |
start a query to match for an specific kind of element
classifier | select kind of event by match on type or ID |
Definition at line 779 of file event-log.cpp.
References EventMatch::locateEvent().
EventMatch verifyCall | ( | string | match | ) | const |
start a query to match especially a function call
match | text to match against the function name |
Definition at line 788 of file event-log.cpp.
References EventMatch::locateCall().
Referenced by BusTerm_test::attachNewBusTerm().
EventMatch ensureNot | ( | string | match | ) | const |
start a query to ensure the given expression does not match.
bool
) will be false
. Definition at line 805 of file event-log.cpp.
References EventMatch::locate(), and EventMatch::look_for_match_.
Referenced by BusTerm_test::attachNewBusTerm(), and EventLog_test::verify_logJoining().