C++Spec 1.0.0
BDD testing for C++
Loading...
Searching...
No Matches
CppSpec::ItD Class Reference

An it embedded in a Description. More...

#include <it.hpp>

Inheritance diagram for CppSpec::ItD:
Collaboration diagram for CppSpec::ItD:

Public Types

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

Public Member Functions

 ItD (std::source_location location, const char *description, Block block)
 The primary ItD constructor.
 ItD (std::source_location location, Block block)
 The anonymous ItD constructor.
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.
ItBase & set_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
Runnable * get_parent () noexcept
 Get the Runnable's parent.
const Runnable * get_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

Detailed Description

An it embedded in a Description.

ItD objects are the representation of an it in a describe block (not a describe_a) the sole item they contain is the function that represents the block of the it. ItD is derived from ItBase.

describe a_thing("A Thing", $ {
it("should have 4", _ { ... });
});

Constructor & Destructor Documentation

◆ ItD() [1/2]

CppSpec::ItD::ItD ( std::source_location location,
const char * description,
Block block )
inline

The primary ItD constructor.

This constructor is used for creating ItDs that are given a documentation string.

it("should exist", _ { ... });
Parameters
parentthe parent of the it (i.e. the Description object)
descriptionthe documentation string of the it
blockthe lambda/function passed to the it
Returns
the constructed ItD object

◆ ItD() [2/2]

CppSpec::ItD::ItD ( std::source_location location,
Block block )
inline

The anonymous ItD constructor.

Not used frequently, as most anonymous its will be ItCD objects, since the syntax lends itself to this. However, the possibility of not giving a documentation string to the it still exists, both to be consistent and for cases it might want to be used.

it(_ { ... });
Parameters
parentthe parent of the it (i.e. the Description object)
blockthe lambda function passed to the it
Returns
the constructed ItD object

Member Function Documentation

◆ run()

void CppSpec::ItD::run ( )
inlineoverridevirtual

Implements CppSpec::Runnable.


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