C++Spec 1.0.0
BDD testing for C++
Loading...
Searching...
No Matches
CppSpec::ClassDescription< T > Class Template Reference

A Description with a defined subject. More...

#include <class_description.hpp>

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

Public Member Functions

 ClassDescription (Block block, std::source_location location=std::source_location::current())
 ClassDescription (const char *description, Block block, std::source_location location=std::source_location::current())
 ClassDescription (const char *description, T &subject, Block block, std::source_location location=std::source_location::current())
template<Util::not_c_string U>
 ClassDescription (U &subject, Block block, std::source_location location=std::source_location::current())
 ClassDescription (const char *description, T &&subject, Block block, std::source_location location=std::source_location::current())
template<Util::not_c_string U>
 ClassDescription (U &&subject, Block block, std::source_location location=std::source_location::current())
template<typename U>
 ClassDescription (std::initializer_list< U > init_list, Block block, std::source_location location=std::source_location::current())
template<typename U>
 ClassDescription (const char *description, std::initializer_list< U > init_list, Block block, std::source_location location=std::source_location::current())
ItCD< T > & it (const char *name, std::function< void(ItCD< T > &)> block, std::source_location location=std::source_location::current())
ItCD< T > & it (std::function< void(ItCD< T > &)> block, std::source_location location=std::source_location::current())
template<class U = std::nullptr_t, class B>
ClassDescription< T > & context (const char *description, B block, std::source_location location=std::source_location::current())
template<class U, class B>
ClassDescription< U > & context (const char *description, U &subject, B block, std::source_location location=std::source_location::current())
template<class U, class B>
ClassDescription< U > & context (U &subject, B block, std::source_location location=std::source_location::current())
template<class U, class B>
ClassDescription< U > & context (const char *description, U &&subject, B block, std::source_location location=std::source_location::current())
template<class U, class B>
ClassDescription< U > & context (U &&subject, B block, std::source_location location=std::source_location::current())
void run () override
std::string get_subject_type () const noexcept override
template<class U, class B>
ClassContext< U > & context (const char *description, U &subject, B block, std::source_location location)
template<class U, class B>
ClassContext< U > & context (const char *description, U &&subject, B block, std::source_location location)
template<class U, class B>
ClassContext< T > & context (const char *description, B block, std::source_location location)
Public Member Functions inherited from CppSpec::Description
 Description (const char *description, Block block, std::source_location location=std::source_location::current()) noexcept
 Description (std::source_location location, std::string &&description) noexcept
 Description (std::source_location location, const char *description, Block block) noexcept
ItDit (const char *name, ItD::Block body, std::source_location location=std::source_location::current())
ItDit (ItD::Block body, std::source_location location=std::source_location::current())
template<class T = std::nullptr_t>
Description & context (const char *description, Block body, std::source_location location=std::source_location::current())
template<Util::not_c_string T, class B>
ClassDescription< T > & context (T &subject, B block, std::source_location location=std::source_location::current())
template<class T, class B>
ClassDescription< T > & context (const char *description, T &subject, B block, std::source_location location=std::source_location::current())
template<Util::not_c_string T, class B>
ClassDescription< T > & context (T &&subject, B block, std::source_location location=std::source_location::current())
template<class T, class B>
ClassDescription< T > & context (const char *description, T &&subject, B block, std::source_location location=std::source_location::current())
template<class T, typename U>
ClassDescription< T > & context (std::initializer_list< U > init_list, std::function< void(ClassDescription< T > &)> block, std::source_location location=std::source_location::current())
void before_each (VoidBlock block)
void before_all (VoidBlock block)
void after_each (VoidBlock block)
void after_all (VoidBlock block)
template<typename F>
auto & let (F factory)
void reset_lets () noexcept
virtual std::string get_description () const noexcept
void run () override
template<typename Formatter>
auto as_main ()
template<Util::not_c_string T, class B>
ClassContext< T > & context (T &subject, B block, std::source_location location)
template<class T, class B>
ClassContext< T > & context (const char *description, T &subject, B block, std::source_location location)
template<Util::not_c_string T, class B>
ClassContext< T > & context (T &&subject, B block, std::source_location location)
template<class T, class B>
ClassContext< T > & context (const char *description, T &&subject, B block, std::source_location location)
template<class T, typename U>
ClassContext< T > & context (std::initializer_list< U > init_list, std::function< void(ClassDescription< T > &)> block, std::source_location location)
template<class T>
Context & context (const char *description, Block body, std::source_location location)
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
virtual Result get_result () const
size_t num_tests () const noexcept
size_t num_failures () const noexcept

Public Attributes

subject
Public Attributes inherited from CppSpec::Description
std::forward_list< LetBase * > lets
std::deque< VoidBlock > after_alls
std::deque< VoidBlock > before_eaches
std::deque< VoidBlock > after_eaches

Additional Inherited Members

Public Types inherited from CppSpec::Description
using Block = std::function<void(Description&)>
Protected Member Functions inherited from CppSpec::Description
void exec_before_eaches ()
void exec_after_eaches ()
Protected Attributes inherited from CppSpec::Description
std::string description

Detailed Description

template<class T>
class CppSpec::ClassDescription< T >

A Description with a defined subject.

A ClassDescription is a subclass of Description that allows for templating and specification of the subject of the tests prior to any it objects.

It is also aliased to the context keyword through Description whenever it is templated, allowing the implicit subject in any child it blocks

Member Function Documentation

◆ get_subject_type()

template<class T>
std::string CppSpec::ClassDescription< T >::get_subject_type ( ) const
inlinenodiscardoverridevirtualnoexcept

Reimplemented from CppSpec::Description.

◆ it() [1/2]

template<class T>
ItCD< T > & CppSpec::ClassDescription< T >::it ( const char * name,
std::function< void(ItCD< T > &)> block,
std::source_location location = std::source_location::current() )

Jasmine-style it declaration, with an explicit docstring provided for verbose printing.

As this is an ItCD, it passes along associated type information about the implicit subject from the containing ClassDescription / ClassContext.

describe_a <std::string> (_{
it("is empty upon initialization", _{
is_expected.to_be_empty();
});
});
ItCD< T > & it(const char *name, std::function< void(ItCD< T > &)> block, std::source_location location=std::source_location::current())
Definition class_description.hpp:237
Parameters
namethe name of the test
blockthe contents of test
Returns
the result of the test

◆ it() [2/2]

template<class T>
ItCD< T > & CppSpec::ClassDescription< T >::it ( std::function< void(ItCD< T > &)> block,
std::source_location location = std::source_location::current() )

Rspec-style it declaration, with an implicit docstring generated by the contained expects. Particularly handy if testing multiple facets of a single behavior and there is a desire to be verbose, as each expectation prints its own docstring.

As this is an ItCD, it passes along associated type information about the implicit subject from the containing ClassDescription / ClassContext.

describe_a <std::string> ("", _{
it(_{ is_expected.to_be_empty(); });
});
Parameters
blockthe contents of the test
Returns
the result of the test

◆ run()

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

Implements CppSpec::Runnable.


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