C++Spec 1.0.0
BDD testing for C++
All Classes Files Functions Variables Pages Concepts
CppSpec::ItCD< T > Class Template Reference

An it embedded in a ClassDescription. More...

#include <it.hpp>

Inheritance diagram for CppSpec::ItCD< T >:
Collaboration diagram for CppSpec::ItCD< T >:

Public Types

using Block = std::function<void(ItCD<T>&)>
 

Public Member Functions

 ItCD (std::source_location location, T &subject, const char *description, Block block)
 
 ItCD (std::source_location location, T &subject, Block block)
 
ExpectationValue< T > is_expected (std::source_location location=std::source_location::current())
 
void run () override
 
- Public Member Functions inherited from CppSpec::ItBase
 ItBase (std::source_location location) noexcept
 Create an BaseIt without an explicit description.
 
 ItBase (std::source_location location, const char *description) noexcept
 Create an BaseIt with an explicit description.
 
bool needs_description () noexcept
 Get whether the object needs a description string.
 
std::string get_description () const noexcept
 Get the description string for the it statement.
 
ItBaseset_description (std::string_view description) noexcept
 Set the description string.
 
template<Util::is_not_functional T>
ExpectationValue< T > expect (T value, std::source_location location=std::source_location::current())
 The expect object generator for objects and LiteralTypes.
 
template<Util::is_functional T>
ExpectationFunc< T > expect (T block, std::source_location location=std::source_location::current())
 The expect object generator for lambdas.
 
template<typename T>
ExpectationValue< std::initializer_list< T > > expect (std::initializer_list< T > init_list, std::source_location location=std::source_location::current())
 The expect object generator for initializer lists.
 
template<typename T>
ExpectationValue< T > expect (Let< T > &let, std::source_location location=std::source_location::current())
 The expect object generator for Let.
 
ExpectationValue< std::string > expect (const char *string, std::source_location location=std::source_location::current())
 The expect object generator for const char*.
 
void add_result (const Result &result)
 
std::list< Result > & get_results () noexcept
 
const std::list< Result > & get_results () const noexcept
 
void clear_results () noexcept
 
Result get_result () const override
 
- Public Member Functions inherited from CppSpec::Runnable
 Runnable (std::source_location location)
 
bool has_parent () noexcept
 Check to see if the Runnable has a parent.
 
bool has_parent () const noexcept
 
Runnableget_parent () noexcept
 Get the Runnable's parent.
 
const Runnableget_parent () const noexcept
 
std::list< std::shared_ptr< Runnable > > & get_children () noexcept
 
const std::list< std::shared_ptr< Runnable > > & get_children () const noexcept
 
template<class C>
C * get_parent_as () noexcept
 
template<class C>
const C * get_parent_as () const noexcept
 
template<typename T, typename... Args>
T * make_child (Args &&... args)
 
std::string padding () const noexcept
 Generate padding (indentation) fore the current object.
 
std::source_location get_location () const noexcept
 
void set_location (std::source_location location) noexcept
 
virtual void timed_run ()
 
std::chrono::duration< double > get_runtime () const
 
std::chrono::time_point< std::chrono::system_clock > get_start_time () const
 
size_t num_tests () const noexcept
 
size_t num_failures () const noexcept
 

Public Attributes

T & subject
 A reference to the parent ClassDescription's subject.
 

Detailed Description

template<typename T>
class CppSpec::ItCD< T >

An it embedded in a ClassDescription.

ItCD objects are the representation of an it in a describe_a block. They contain both the function that represents the block of the it, and a reference to the parent ClassDescription::subject

Template Parameters
Tthe type of the subject of the parent ClassDescription (ClassDescription<T>)

Member Function Documentation

◆ run()

template<class T>
void CppSpec::ItCD< T >::run ( )
overridevirtual

Implements CppSpec::Runnable.

Member Data Documentation

◆ subject

template<typename T>
T& CppSpec::ItCD< T >::subject

A reference to the parent ClassDescription's subject.

Public so that we can easily do expect(subject) without needing to have a dedicated macro for accessing the subject via getter, or needing to introduce parenthesis for call syntax (like subject())


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