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  BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< std::nullptr_t >
 
struct  PRINTABLE_OPT< T >
 
struct  BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< std::vector< T > >
 Boost print helper for generic vectors. More...
 
struct  BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< wxPoint >
 Boost print helper for wxPoint. More...
 

Namespaces

namespace  BOOST_TEST_PRINT_NAMESPACE_OPEN
 Before Boost 1.64, nullptr_t wasn't handled.
 
namespace  KI_TEST
 

Macros

#define BOOST_NO_AUTO_PTR
 
#define BOOST_TEST_INFO(A)   BOOST_TEST_MESSAGE( A )
 If HAVE_EXPECTED_FAILURES is defined, this means that boost::unit_test::expected_failures is available.
 
#define BOOST_TEST_CONTEXT(A)   BOOST_TEST_MESSAGE( A );
 
#define BOOST_TEST_PRINT_NAMESPACE_OPEN
 
#define BOOST_TEST_PRINT_NAMESPACE_CLOSE   }
 
#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 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.

◆ BOOST_TEST_CONTEXT

#define BOOST_TEST_CONTEXT (   A)    BOOST_TEST_MESSAGE( A );

Definition at line 84 of file unit_test_utils.h.

◆ BOOST_TEST_INFO

#define BOOST_TEST_INFO (   A)    BOOST_TEST_MESSAGE( A )

If HAVE_EXPECTED_FAILURES is defined, this means that boost::unit_test::expected_failures is available.

Wrap expected-to-fail tests with this to prevent them being compiled on platforms with older (<1.59) Boost versions.

This can be removed when our minimum boost version is 1.59 or higher. BOOST_TEST, while extremely handy, is not available in Boost < 1.59. Undef it here to prevent use. Using it can cause older packaging like Ubuntu LTS (which is on Boost 1.58) to fail.

Use BOOST_CHECK_{EQUAL,NE,etc} instead.

This can be removed when our minimum boost version is 1.59 or higher.

Definition at line 74 of file unit_test_utils.h.

◆ BOOST_TEST_PRINT_NAMESPACE_CLOSE

#define BOOST_TEST_PRINT_NAMESPACE_CLOSE   }

Definition at line 114 of file unit_test_utils.h.

◆ BOOST_TEST_PRINT_NAMESPACE_OPEN

#define BOOST_TEST_PRINT_NAMESPACE_OPEN
Value:
boost \
{ \
namespace test_tools

Definition at line 110 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 348 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 154 of file unit_test_utils.h.

Function Documentation

◆ operator!=()

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

Definition at line 181 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 159 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 171 of file unit_test_utils.h.

References PRINTABLE_OPT< T >::m_Opt.