KiCad PCB EDA Suite
unit_test_utils.h File Reference
#include <boost/test/unit_test.hpp>
#include <unit_test_utils/wx_assert.h>
#include <functional>
#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  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

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

Macros

#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. More...
 
#define BOOST_TEST_CONTEXT(A)   BOOST_TEST_MESSAGE( A );
 
#define BOOST_TEST_PRINT_NAMESPACE_OPEN
 
#define BOOST_TEST_PRINT_NAMESPACE_CLOSE   }
 
#define CHECK_WX_ASSERT(STATEMENT)
 A test macro to check a wxASSERT is thrown. More...
 

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. More...
 

Functions

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. More...
 
template<typename T >
bool KI_TEST::CollectionHasNoDuplicates (const T &aCollection)
 Predicate to check a collection has no duplicate elements. More...
 

Macro Definition Documentation

◆ BOOST_TEST_CONTEXT

#define BOOST_TEST_CONTEXT (   A)    BOOST_TEST_MESSAGE( A );

Definition at line 79 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 69 of file unit_test_utils.h.

◆ BOOST_TEST_PRINT_NAMESPACE_CLOSE

#define BOOST_TEST_PRINT_NAMESPACE_CLOSE   }

Definition at line 109 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 105 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 295 of file unit_test_utils.h.