actor-framework
Public Types | Public Member Functions | Public Attributes | List of all members
caf::test::context Class Reference

Represents the execution context of a test. More...

#include <context.hpp>

Public Types

using parameter_map = std::map< std::string, std::string >
 Stores the parameters for a test run.
 
using step_id = std::pair< int, size_t >
 The ID of a step in the test.
 

Public Member Functions

 context (const context &)=delete
 
contextoperator= (const context &)=delete
 
bool active () const noexcept
 Returns whether the test is still active. More...
 
bool can_run () const noexcept
 Checks whether this block has at least one branch that can be executed.
 
bool activated (block *ptr) const noexcept
 Checks whether ptr has been activated this run, i.e., whether we can find it in unwind_stack. More...
 
const std::string & parameter (const std::string &name) const
 Tries to find name in parameters and otherwise raises an exception.
 
void clear_stacks ()
 Clears the call and unwind stacks.
 
void on_enter (block *ptr)
 Callback for block::enter.
 
void on_leave (block *ptr)
 Callback for block::leave.
 
template<class T >
T * get (int id, std::string_view description, const detail::source_location &loc)
 Returns a new block with the given ID or creates a new one if necessary.
 
template<class T >
T * find_predecessor (int caller_id)
 Tries to find the first step that immediately precedes caller_id in the execution path. More...
 

Public Attributes

std::vector< block * > call_stack
 Stores the current execution stack for the run.
 
std::vector< block * > unwind_stack
 Stores the steps that finished execution this run.
 
std::vector< block * > path
 Stores all steps that we have reached at least once during the run.
 
std::map< step_id, std::unique_ptr< block > > steps
 Stores all steps of the test with their run-time ID.
 
parameter_map parameters
 Stores the parameters for the current run.
 
size_t example_id = 0
 Stores the current example ID.
 
std::vector< parameter_mapexample_parameters
 Stores the parameters for each example.
 
std::vector< std::string > example_names
 Stores the names of each example.
 

Detailed Description

Represents the execution context of a test.

The context stores all steps of the test and the current execution stack. The context persists across multiple runs of the test in order to select one execution path per run.

Member Function Documentation

◆ activated()

bool caf::test::context::activated ( block ptr) const
noexcept

Checks whether ptr has been activated this run, i.e., whether we can find it in unwind_stack.

◆ active()

bool caf::test::context::active ( ) const
noexcept

Returns whether the test is still active.

A test is active as long as no unwinding is in progress.

◆ find_predecessor()

template<class T >
T* caf::test::context::find_predecessor ( int  caller_id)
inline

Tries to find the first step that immediately precedes caller_id in the execution path.

Returns nullptr if no such step exists.


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