KiCad PCB EDA Suite
Loading...
Searching...
No Matches
unit_test_utils.h File Reference
#include <boost/test/unit_test.hpp>
#include <turtle/mock.hpp>
#include <qa_utils/wx_utils/wx_assert.h>
#include <functional>
#include <optional>
#include <set>
#include <wx/gdicmn.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  PRINTABLE_OPT< T >
 
struct  boost::test_tools::tt_detail::print_log_value< wxString >
 
struct  boost::test_tools::tt_detail::print_log_value< wchar_t[N]>
 
struct  KI_TEST::NAMED_CASE
 A named data-driven test case. More...
 

Namespaces

namespace  std
 STL namespace.
 
namespace  boost
 
namespace  boost::test_tools
 
namespace  boost::test_tools::tt_detail
 
namespace  KI_TEST
 

Macros

#define BOOST_NO_AUTO_PTR
 
#define KI_CHECK_OPT_EQUAL(lhs, rhs)
 Work around to allow printing std::optional types.
 
#define CHECK_WX_ASSERT(STATEMENT)
 A test macro to check a wxASSERT is thrown.
 

Typedefs

template<typename EXP_CONT>
using KI_TEST::EXP_OBJ = typename EXP_CONT::value_type
 
template<typename FOUND_CONT>
using KI_TEST::FOUND_OBJ = typename FOUND_CONT::value_type
 
template<typename EXP_OBJ, typename FOUND_OBJ>
using KI_TEST::MATCH_PRED = std::function<bool( const EXP_OBJ&, const FOUND_OBJ& )>
 A match predicate: check that a "found" object is equivalent to or represents an "expected" object, perhaps of a different type.
 

Functions

template<class T>
std::ostream & operator<< (std::ostream &aOs, const PRINTABLE_OPT< T > &aOptional)
 
template<class L, class R>
bool operator== (const PRINTABLE_OPT< L > &aLhs, const PRINTABLE_OPT< R > &aRhs)
 
template<class L, class R>
bool operator!= (const PRINTABLE_OPT< L > &aLhs, const PRINTABLE_OPT< R > &aRhs)
 
template<typename T>
std::ostream & std::boost_test_print_type (std::ostream &os, std::vector< T > const &aVec)
 Boost print helper for generic vectors.
 
template<typename K, typename V>
std::ostream & std::boost_test_print_type (std::ostream &os, std::map< K, V > const &aMap)
 Boost print helper for generic maps.
 
template<typename K, typename V>
std::ostream & std::boost_test_print_type (std::ostream &os, std::pair< K, V > const &aPair)
 Boost print helper for generic pairs.
 
std::ostream & boost_test_print_type (std::ostream &os, wxPoint const &aVec)
 Boost print helper for wxPoint.
 
template<typename EXP_CONT, typename FOUND_CONT, typename MATCH_PRED>
void KI_TEST::CheckUnorderedMatches (const EXP_CONT &aExpected, const FOUND_CONT &aFound, MATCH_PRED aMatchPredicate)
 Check that a container of "found" objects matches a container of "expected" objects.
 
template<typename T>
bool KI_TEST::CollectionHasNoDuplicates (const T &aCollection)
 Predicate to check a collection has no duplicate elements.
 
std::string KI_TEST::GetEeschemaTestDataDir ()
 Get the configured location of Eeschema test data.
 
std::string KI_TEST::GetTestDataRootDir ()
 
void KI_TEST::SetMockConfigDir ()
 

Macro Definition Documentation

◆ BOOST_NO_AUTO_PTR

#define BOOST_NO_AUTO_PTR

Definition at line 27 of file unit_test_utils.h.

◆ CHECK_WX_ASSERT

#define CHECK_WX_ASSERT ( STATEMENT)

A test macro to check a wxASSERT is thrown.

This only happens in DEBUG builds, so prevent test failures in Release builds by using this macro.

Definition at line 324 of file unit_test_utils.h.

Referenced by BOOST_AUTO_TEST_CASE().

◆ KI_CHECK_OPT_EQUAL

#define KI_CHECK_OPT_EQUAL ( lhs,
rhs )
Value:
BOOST_CHECK_EQUAL(result, "25.4")

Work around to allow printing std::optional types.

Definition at line 56 of file unit_test_utils.h.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

Function Documentation

◆ boost_test_print_type()

std::ostream & boost_test_print_type ( std::ostream & os,
wxPoint const & aVec )

Boost print helper for wxPoint.

Note operator<< for this type doesn't exist in non-DEBUG builds.

Definition at line 27 of file unit_test_utils.cpp.

◆ operator!=()

template<class L, class R>
bool operator!= ( const PRINTABLE_OPT< L > & aLhs,
const PRINTABLE_OPT< R > & aRhs )
inline

Definition at line 83 of file unit_test_utils.h.

◆ operator<<()

template<class T>
std::ostream & operator<< ( std::ostream & aOs,
const PRINTABLE_OPT< T > & aOptional )
inline

Definition at line 61 of file unit_test_utils.h.

References PRINTABLE_OPT< T >::m_Opt.

◆ operator==()

template<class L, class R>
bool operator== ( const PRINTABLE_OPT< L > & aLhs,
const PRINTABLE_OPT< R > & aRhs )
inline

Definition at line 73 of file unit_test_utils.h.

References PRINTABLE_OPT< T >::m_Opt.