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>

Go to the source code of this file.

Classes

struct  PRINTABLE_OPT< T >
 

Namespaces

namespace  std
 STL namespace.
 
namespace  KI_TEST
 

Macros

#define BOOST_NO_AUTO_PTR
 
#define KI_CHECK_OPT_EQUAL(lhs, rhs)    BOOST_CHECK_EQUAL( PRINTABLE_OPT( lhs ), PRINTABLE_OPT( 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.
 

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 270 of file unit_test_utils.h.

◆ KI_CHECK_OPT_EQUAL

#define KI_CHECK_OPT_EQUAL (   lhs,
  rhs 
)     BOOST_CHECK_EQUAL( PRINTABLE_OPT( lhs ), PRINTABLE_OPT( rhs ) )

Work around to allow printing std::optional types.

Definition at line 55 of file unit_test_utils.h.

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 26 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 82 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 60 of file unit_test_utils.h.

References PRINTABLE_OPT< T >::m_Opt, and operator<<().

◆ operator==()

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

Definition at line 72 of file unit_test_utils.h.

References PRINTABLE_OPT< T >::m_Opt.