KiCad PCB EDA Suite
KI_TEST Namespace Reference

Classes

class  BOARD_DUMPER
 A helper that contains logic to assist in dumping boards to disk depending on some environment variables. More...
 
class  COMBINED_UTILITY
 Class that handles delegation of command lines to one of a number of "sub-utilities". More...
 
struct  CommonTestData
 Common data for some of the SHAPE_POLY_SET tests: More...
 
struct  kitest_cmp_drawings
 
class  SCHEMATIC_TEST_FIXTURE
 A generic fixture for loading schematics and associated settings for qa tests. More...
 
struct  UTILITY_PROGRAM
 Description of a "utility program", which is a program that takes some command line and does "something". More...
 
class  WX_ASSERT_ERROR
 An exception class to represent a WX assertion. More...
 

Typedefs

template<typename EXP_CONT >
using EXP_OBJ = typename EXP_CONT::value_type
 
template<typename FOUND_CONT >
using FOUND_OBJ = typename FOUND_CONT::value_type
 
template<typename EXP_OBJ , typename FOUND_OBJ >
using 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...
 

Enumerations

enum  RET_CODES { OK = 0 , BAD_CMDLINE = 1 , UNKNOWN_TOOL = 2 , TOOL_SPECIFIC = 10 }
 Return codes for tools. More...
 

Functions

void DrawSegment (FOOTPRINT &aFootprint, const SEG &aSeg, int aWidth, PCB_LAYER_ID aLayer)
 Draw a segment in the given footprint. More...
 
void DrawPolyline (FOOTPRINT &aFootprint, const std::vector< VECTOR2I > &aPts, int aWidth, PCB_LAYER_ID aLayer)
 Draw a polyline - a set of linked segments. More...
 
void DrawArc (FOOTPRINT &aFootprint, const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aAngle, int aWidth, PCB_LAYER_ID aLayer)
 Draw an arc on a footprint. More...
 
void DrawRect (FOOTPRINT &aFootprint, const VECTOR2I &aPos, const VECTOR2I &aSize, int aRadius, int aWidth, PCB_LAYER_ID aLayer)
 Draw a rectangle on a footprint. More...
 
std::string GetPcbnewTestDataDir ()
 Utility which returns a path to the data directory where the test board files are stored. More...
 
void DumpBoardToFile (BOARD &aBoard, const std::string &aFilename)
 Utility function to simply write a Board out to a file. More...
 
std::unique_ptr< BOARD_ITEMReadBoardItemFromStream (std::istream &aStream)
 Utility function to read a BOARD_ITEM (probably a FOOTPRINT or a BOARD) from a file. More...
 
std::unique_ptr< BOARDReadBoardFromFileOrStream (const std::string &aFilename, std::istream &aFallback=std::cin)
 Read a board from a file, or another stream, as appropriate. More...
 
void LoadBoard (SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
 
void FillZones (BOARD *m_board)
 
void CheckFootprint (const FOOTPRINT *expected, const FOOTPRINT *fp)
 Helper method to check if two footprints are semantically the same. More...
 
void CheckFpPad (const PAD *expected, const PAD *pad)
 
void CheckFpText (const FP_TEXT *expected, const FP_TEXT *text)
 
void CheckFpShape (const FP_SHAPE *expected, const FP_SHAPE *shape)
 
void CheckFpZone (const FP_ZONE *expected, const FP_ZONE *zone)
 
void CheckShapePolySet (const SHAPE_POLY_SET *expected, const SHAPE_POLY_SET *polyset)
 
template<typename ITEM >
std::unique_ptr< ITEM > ReadItemFromStream (std::istream &aStream)
 Read a specific kind of BOARD_ITEM from a stream. More...
 
SHAPE_LINE_CHAIN BuildRectChain (const VECTOR2I &aSize, const VECTOR2I &aCentre={ 0, 0 })
 Builds a rectangular SHAPE_LINE_CHAIN of a certain size at a certain centre. More...
 
SHAPE_LINE_CHAIN BuildSquareChain (int aSize, const VECTOR2I &aCentre={ 0, 0 })
 Builds a square SHAPE_LINE_CHAIN of a certain size at a certain centre. More...
 
SHAPE_POLY_SET BuildPolyset (const std::vector< SHAPE_LINE_CHAIN > &aOutlines)
 Construct a SHAPE_POLY_SET from a list of points for each of outlines (no holes) More...
 
SHAPE_POLY_SET BuildHollowSquare (int aOuterSize, int aInnerSize, const VECTOR2I &aCentre={ 0, 0 })
 Build a SHAPE_POLY_SET in the shape of a square outline, with a square hole, both centred at the given point. More...
 
SEG BuildHSeg (const VECTOR2I &aStart, int aLength)
 Build a horizontal segment from a point with a length. More...
 
SEG BuildVSeg (const VECTOR2I &aStart, int aLength)
 Build a vertical segment from a point with a length. More...
 
template<typename VEC >
bool IsVecWithinTol (const VEC &aVec, const VEC &aExp, typename VEC::coord_type aTol)
 Check that both x and y of a vector are within expected error. More...
 
template<typename BOX >
bool IsBoxWithinTol (const BOX &aBox, const BOX &aExp, typename BOX::coord_type aTol)
 Check that a box is close enough to another box. More...
 
template<typename T >
bool IsWithinWrapped (T aValue, T aNominal, T aWrap, T aError)
 Check if a value is within a tolerance of a nominal value, wrapping to a given val. More...
 
template<typename T >
bool IsWithin (T aValue, T aNominal, T aError)
 Check if a value is within a tolerance of a nominal value. More...
 
template<typename T >
bool IsWithinBounds (T aValue, T aNominal, T aErrorAbove, T aErrorBelow)
 Check if a value is within a tolerance of a nominal value, with different allowances for errors above and below. More...
 
template<typename T >
bool IsWithinAndBelow (T aValue, T aNominal, T aErrorBelow)
 value is in range [aNominal - aErrorBelow, aNominal] More...
 
template<typename T >
bool IsWithinAndAbove (T aValue, T aNominal, T aErrorAbove)
 value is in range [aNominal, aNominal + aErrorAbove] More...
 
template<typename EXP_CONT , typename FOUND_CONT , typename MATCH_PRED >
void 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 CollectionHasNoDuplicates (const T &aCollection)
 Predicate to check a collection has no duplicate elements. More...
 
std::string getEeschemaTestDataDir ()
 
void DumpSchematicToFile (SCHEMATIC &aSchematic, SCH_SHEET &aSheet, const std::string &aFilename)
 
std::unique_ptr< SCHEMATICReadSchematicFromStream (std::istream &aStream, PROJECT *aProject)
 
std::unique_ptr< SCHEMATICReadSchematicFromFile (const std::string &aFilename, PROJECT *aProject)
 
void LoadSchematic (SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
 
bool IsColorNear (const KIGFX::COLOR4D &aCol, const KIGFX::COLOR4D aOther, double aTol)
 Checks if a COLOR4D is close enough to another. More...
 
bool IsColorNearHex (const KIGFX::COLOR4D &aCol, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 Checks if a COLOR4D is close enough to a given RGB char value. More...
 
bool IsImagePixelOfColor (const wxImage &aImage, int aX, int aY, const KIGFX::COLOR4D &aColor)
 Predicate to check an image pixel matches color and alpha. More...
 
wxFileName GetEeschemaTestDataDir ()
 Get the configured location of Eeschema test data. More...
 
bool FieldNameIdMatches (const LIB_FIELD &aField, const std::string &aExpectedName, int aExpectedId)
 Predicate to check a field name is as expected. More...
 
bool AreDefaultFieldsCorrect (const std::vector< LIB_FIELD > &aFields)
 Predicate to check that the mandatory fields in a LIB_FIELDS object look sensible. More...
 
bool IsUUID (const std::string &aStr)
 Check if the string between the iterators looks like a UUID. More...
 
bool IsUUIDPathWithLevels (const std::string &aStr, unsigned aLevels)
 Predicate to check a string is a UUID path format. More...
 
SEXPR::SEXPR_TYPE getType (const SEXPR::SEXPR &aSexpr)
 Get the type of the s-expression. More...
 
std::string getDebugType (SEXPR::SEXPR_TYPE aType)
 Get a debug-friendly string for a given s-expr type. More...
 
std::string GetSexprDebugType (const SEXPR::SEXPR &aSexpr)
 
bool IsSexprOfType (const SEXPR::SEXPR &aSexpr, SEXPR::SEXPR_TYPE aType)
 
template<typename VAL_T >
bool IsSexprValueEqual (const VAL_T &aGot, const VAL_T &aExpected)
 Predicate to check two s-expr values (of the same type) are equal. More...
 
bool SexprIsSymbol (const SEXPR::SEXPR &aSexpr)
 Test predicate: is the s-expression a symbol? More...
 
bool SexprIsSymbolWithValue (const SEXPR::SEXPR &aSexpr, const std::string &aVal)
 Test predicate: is the s-expression a symbol with the given value? More...
 
bool SexprIsString (const SEXPR::SEXPR &aSexpr)
 Test predicate: is the s-expression a string? More...
 
bool SexprIsStringWithValue (const SEXPR::SEXPR &aSexpr, const std::string &aVal)
 Test predicate: is the s-expression a string with the given value? More...
 
bool SexprIsInteger (const SEXPR::SEXPR &aSexpr)
 Test predicate: is the s-expression an integer? More...
 
bool SexprIsIntegerWithValue (const SEXPR::SEXPR &aSexpr, std::int64_t aVal)
 Test predicate: is the s-expression an integer with the given value? More...
 
bool SexprIsDouble (const SEXPR::SEXPR &aSexpr)
 Test predicate: is the s-expression a double? More...
 
bool SexprIsDoubleWithValue (const SEXPR::SEXPR &aSexpr, double aVal)
 Test predicate: is the s-expression a double with the given value? More...
 
bool SexprIsList (const SEXPR::SEXPR &aSexpr)
 Test predicate: is the s-expression a double? More...
 
bool SexprIsListOfLength (const SEXPR::SEXPR &aSexpr, size_t aExpectedLength)
 Test predicate: is the s-expression a list with the given length? More...
 
bool SexprConvertsToString (const SEXPR::SEXPR &aSexpr, const std::string &aExpStr)
 Predicate to check an SEXPR object converts to the expected string. More...
 
bool IsDrcMarkerOfType (const PCB_MARKER &aMarker, int aErrorCode)
 Predicate for testing the type of a DRC marker. More...
 

Typedef Documentation

◆ EXP_OBJ

template<typename EXP_CONT >
using KI_TEST::EXP_OBJ = typedef typename EXP_CONT::value_type

Definition at line 178 of file unit_test_utils.h.

◆ FOUND_OBJ

template<typename FOUND_CONT >
using KI_TEST::FOUND_OBJ = typedef typename FOUND_CONT::value_type

Definition at line 179 of file unit_test_utils.h.

◆ MATCH_PRED

template<typename EXP_OBJ , typename FOUND_OBJ >
using KI_TEST::MATCH_PRED = typedef 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.

Exactly what "equivalent to" means depends heavily on the context and what is care about. For example, if you only care about a FOOTPRINT's refdes, std::string is sufficient to indicate a "match".

This can be used, for example, for checking a set of results without having to instantiate a full result object for checking by equality.

Template Parameters
EXP_OBJthe "expected" object type
FOUND_OBJthe "found" object type
Returns
true if the "found" object represents the "expected" object

Definition at line 198 of file unit_test_utils.h.

Enumeration Type Documentation

◆ RET_CODES

Return codes for tools.

Enumerator
OK 

Tool exited OK.

BAD_CMDLINE 

The command line was not correct for the tool.

UNKNOWN_TOOL 

The tool asked for was not found.

TOOL_SPECIFIC 

Tools can define their own statuses from here onwards.

Definition at line 38 of file utility_program.h.

39{
41 OK = 0,
42
44 BAD_CMDLINE = 1,
45
47 UNKNOWN_TOOL = 2,
48
50 TOOL_SPECIFIC = 10,
51};
@ OK
Tool exited OK.
@ UNKNOWN_TOOL
The tool asked for was not found.
@ TOOL_SPECIFIC
Tools can define their own statuses from here onwards.
@ BAD_CMDLINE
The command line was not correct for the tool.

Function Documentation

◆ AreDefaultFieldsCorrect()

bool KI_TEST::AreDefaultFieldsCorrect ( const std::vector< LIB_FIELD > &  aFields)

Predicate to check that the mandatory fields in a LIB_FIELDS object look sensible.

Parameters
aFieldsthe fields to check
Returns
true if valid

Definition at line 98 of file lib_field_test_utils.h.

99{
100 const unsigned expectedCount = MANDATORY_FIELD_T::MANDATORY_FIELDS;
101 if( aFields.size() < expectedCount )
102 {
104 "Expected at least " << expectedCount << " fields, got " << aFields.size() );
105 return false;
106 }
107
108 bool ok = true;
109
110 ok &= FieldNameIdMatches( aFields[0], "Reference", MANDATORY_FIELD_T::REFERENCE_FIELD );
111 ok &= FieldNameIdMatches( aFields[1], "Value", MANDATORY_FIELD_T::VALUE_FIELD );
112 ok &= FieldNameIdMatches( aFields[2], "Footprint", MANDATORY_FIELD_T::FOOTPRINT_FIELD );
113 ok &= FieldNameIdMatches( aFields[3], "Datasheet", MANDATORY_FIELD_T::DATASHEET_FIELD );
114
115 return ok;
116}
bool FieldNameIdMatches(const LIB_FIELD &aField, const std::string &aExpectedName, int aExpectedId)
Predicate to check a field name is as expected.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
#define BOOST_TEST_INFO(A)
If HAVE_EXPECTED_FAILURES is defined, this means that boost::unit_test::expected_failures is availabl...

References BOOST_TEST_INFO, DATASHEET_FIELD, FieldNameIdMatches(), FOOTPRINT_FIELD, MANDATORY_FIELDS, REFERENCE_FIELD, and VALUE_FIELD.

Referenced by BOOST_AUTO_TEST_CASE().

◆ BuildHollowSquare()

SHAPE_POLY_SET KI_TEST::BuildHollowSquare ( int  aOuterSize,
int  aInnerSize,
const VECTOR2I aCentre = { 0, 0 } 
)

Build a SHAPE_POLY_SET in the shape of a square outline, with a square hole, both centred at the given point.

Parameters
aOuterSizethe size (x and y) of the outer square
aInnerSizethe size (x and y) of the hole
aCentrethe centre point of both squares (default: origin)
Returns
a SHAPE_POLY_SET of the desired shape

Definition at line 44 of file poly_set_construction.cpp.

45{
46 SHAPE_POLY_SET polyset;
47
48 polyset.AddOutline( BuildRectChain( { aOuterSize, aOuterSize }, aCentre ) );
49 polyset.AddHole( BuildRectChain( { aInnerSize, aInnerSize }, aCentre ) );
50
51 return polyset;
52}
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Return the area of this poly set.
SHAPE_LINE_CHAIN BuildRectChain(const VECTOR2I &aSize, const VECTOR2I &aCentre)
Builds a rectangular SHAPE_LINE_CHAIN of a certain size at a certain centre.

References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), and BuildRectChain().

Referenced by GetSPSSegDistCases().

◆ BuildHSeg()

SEG KI_TEST::BuildHSeg ( const VECTOR2I aStart,
int  aLength 
)

Build a horizontal segment from a point with a length.

Parameters
aStartthe starting point
aLengththe segment length
Returns
the resulting segment

Definition at line 29 of file seg_construction.cpp.

30{
31 return SEG{ { aStart.x, aStart.y }, { aStart.x + aLength, aStart.y } };
32}
Definition: seg.h:42

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetSPSSegDistCases().

◆ BuildPolyset()

SHAPE_POLY_SET KI_TEST::BuildPolyset ( const std::vector< SHAPE_LINE_CHAIN > &  aOutlines)

Construct a SHAPE_POLY_SET from a list of points for each of outlines (no holes)

Definition at line 31 of file poly_set_construction.cpp.

32{
33 SHAPE_POLY_SET polyset;
34
35 for( const auto& outline : aOutlines )
36 {
37 polyset.AddOutline( outline );
38 }
39
40 return polyset;
41}

References SHAPE_POLY_SET::AddOutline().

Referenced by GetSPSSegDistCases().

◆ BuildRectChain()

SHAPE_LINE_CHAIN KI_TEST::BuildRectChain ( const VECTOR2I aSize,
const VECTOR2I aCentre = { 0, 0 } 
)

Builds a rectangular SHAPE_LINE_CHAIN of a certain size at a certain centre.

Parameters
aSizethe rectangle size
aCentrecentre of the rectangle
Returns
a closed line chain of the rectangle

Definition at line 29 of file line_chain_construction.cpp.

30{
31 const std::vector<VECTOR2I> pts = {
32 { aCentre.x - aSize.x / 2, aCentre.y - aSize.y / 2 },
33 { aCentre.x - aSize.x / 2, aCentre.y + aSize.y / 2 },
34 { aCentre.x + aSize.x / 2, aCentre.y + aSize.y / 2 },
35 { aCentre.x + aSize.x / 2, aCentre.y - aSize.y / 2 },
36 };
37
38 SHAPE_LINE_CHAIN chain( pts );
39 chain.SetClosed( true );
40
41 return chain;
42}
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...

References SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BuildHollowSquare(), and BuildSquareChain().

◆ BuildSquareChain()

SHAPE_LINE_CHAIN KI_TEST::BuildSquareChain ( int  aSize,
const VECTOR2I aCentre = { 0, 0 } 
)

Builds a square SHAPE_LINE_CHAIN of a certain size at a certain centre.

Parameters
aSizethe square size (x == y)
aCentrecentre of the square
Returns
a closed line chain of the square

Definition at line 44 of file line_chain_construction.cpp.

45{
46 return BuildRectChain( { aSize, aSize }, aCentre );
47}

References BuildRectChain().

Referenced by GetSPSSegDistCases().

◆ BuildVSeg()

SEG KI_TEST::BuildVSeg ( const VECTOR2I aStart,
int  aLength 
)

Build a vertical segment from a point with a length.

Parameters
aStartthe starting point
aLengththe segment length
Returns
the resulting segment

Definition at line 34 of file seg_construction.cpp.

35{
36 return SEG{ { aStart.x, aStart.y }, { aStart.x, aStart.y + aLength } };
37}

References VECTOR2< T >::x, and VECTOR2< T >::y.

◆ CheckFootprint()

void KI_TEST::CheckFootprint ( const FOOTPRINT expected,
const FOOTPRINT fp 
)

Helper method to check if two footprints are semantically the same.

Definition at line 165 of file board_test_utils.cpp.

166{
167 CHECK_ENUM_CLASS_EQUAL( expected->Type(), fp->Type() );
168
169 // TODO: validate those informations match the importer
170 BOOST_CHECK_EQUAL( expected->GetPosition(), fp->GetPosition() );
171 BOOST_CHECK_EQUAL( expected->GetOrientation(), fp->GetOrientation() );
172
173 BOOST_CHECK_EQUAL( expected->GetReference(), fp->GetReference() );
174 BOOST_CHECK_EQUAL( expected->GetValue(), fp->GetValue() );
175 BOOST_CHECK_EQUAL( expected->GetDescription(), fp->GetDescription() );
176 BOOST_CHECK_EQUAL( expected->GetKeywords(), fp->GetKeywords() );
177 BOOST_CHECK_EQUAL( expected->GetAttributes(), fp->GetAttributes() );
178 BOOST_CHECK_EQUAL( expected->GetFlag(), fp->GetFlag() );
179 //BOOST_CHECK_EQUAL( expected->GetProperties(), fp->GetProperties() );
180 BOOST_CHECK_EQUAL( expected->GetTypeName(), fp->GetTypeName() );
181
182 // simple test if count matches
183 BOOST_CHECK_EQUAL( expected->Pads().size(), fp->Pads().size() );
184 BOOST_CHECK_EQUAL( expected->GraphicalItems().size(), fp->GraphicalItems().size() );
185 BOOST_CHECK_EQUAL( expected->Zones().size(), fp->Zones().size() );
186 BOOST_CHECK_EQUAL( expected->Groups().size(), fp->Groups().size() );
187 BOOST_CHECK_EQUAL( expected->Models().size(), fp->Models().size() );
188
189 std::set<PAD*, FOOTPRINT::cmp_pads> expectedPads( expected->Pads().begin(),
190 expected->Pads().end() );
191 std::set<PAD*, FOOTPRINT::cmp_pads> fpPads( fp->Pads().begin(), fp->Pads().end() );
192 for( auto itExpected = expectedPads.begin(), itFp = fpPads.begin();
193 itExpected != expectedPads.end() && itFp != fpPads.end(); itExpected++, itFp++ )
194 {
195 CheckFpPad( *itExpected, *itFp );
196 }
197
198 std::set<BOARD_ITEM*, kitest_cmp_drawings> expectedGraphicalItems(
199 expected->GraphicalItems().begin(), expected->GraphicalItems().end() );
200 std::set<BOARD_ITEM*, kitest_cmp_drawings> fpGraphicalItems( fp->GraphicalItems().begin(),
201 fp->GraphicalItems().end() );
202 for( auto itExpected = expectedGraphicalItems.begin(), itFp = fpGraphicalItems.begin();
203 itExpected != expectedGraphicalItems.end() && itFp != fpGraphicalItems.end();
204 itExpected++, itFp++ )
205 {
206 BOOST_CHECK_EQUAL( ( *itExpected )->Type(), ( *itFp )->Type() );
207 switch( ( *itExpected )->Type() )
208 {
209 case PCB_FP_TEXT_T:
210 {
211 const FP_TEXT* expectedText = static_cast<const FP_TEXT*>( *itExpected );
212 const FP_TEXT* text = static_cast<const FP_TEXT*>( *itFp );
213
214 CheckFpText( expectedText, text );
215 }
216 break;
217 case PCB_FP_SHAPE_T:
218 {
219 const FP_SHAPE* expectedShape = static_cast<const FP_SHAPE*>( *itExpected );
220 const FP_SHAPE* shape = static_cast<const FP_SHAPE*>( *itFp );
221
222 CheckFpShape( expectedShape, shape );
223 }
224 break;
225 /*case PCB_FP_DIM_ALIGNED_T: break;
226 case PCB_FP_DIM_LEADER_T: break;
227 case PCB_FP_DIM_CENTER_T: break;
228 case PCB_FP_DIM_RADIAL_T: break;
229 case PCB_FP_DIM_ORTHOGONAL_T: break;*/
230 default: BOOST_ERROR( "KICAD_T not known" ); break;
231 }
232 }
233
234 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> expectedZones( expected->Zones().begin(),
235 expected->Zones().end() );
236 std::set<FP_ZONE*, FOOTPRINT::cmp_zones> fpZones( fp->Zones().begin(), fp->Zones().end() );
237 for( auto itExpected = expectedZones.begin(), itFp = fpZones.begin();
238 itExpected != expectedZones.end() && itFp != fpZones.end(); itExpected++, itFp++ )
239 {
240 CheckFpZone( *itExpected, *itFp );
241 }
242
243 // TODO: Groups
244}
#define CHECK_ENUM_CLASS_EQUAL(L, R)
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:111
EDA_ANGLE GetOrientation() const
Definition: footprint.h:195
const wxString & GetKeywords() const
Definition: footprint.h:216
FP_GROUPS & Groups()
Definition: footprint.h:183
int GetAttributes() const
Definition: footprint.h:245
PADS & Pads()
Definition: footprint.h:174
wxString GetTypeName() const
Get the type of footprint.
Definition: footprint.cpp:749
const wxString & GetDescription() const
Definition: footprint.h:213
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:188
const wxString & GetValue() const
Definition: footprint.h:541
const wxString & GetReference() const
Definition: footprint.h:519
int GetFlag() const
Definition: footprint.h:250
FP_ZONES & Zones()
Definition: footprint.h:180
VECTOR2I GetPosition() const override
Definition: footprint.h:192
DRAWINGS & GraphicalItems()
Definition: footprint.h:177
void CheckFpZone(const FP_ZONE *expected, const FP_ZONE *zone)
void CheckFpPad(const PAD *expected, const PAD *pad)
void CheckFpShape(const FP_SHAPE *expected, const FP_SHAPE *shape)
void CheckFpText(const FP_TEXT *expected, const FP_TEXT *text)
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References CHECK_ENUM_CLASS_EQUAL, CheckFpPad(), CheckFpShape(), CheckFpText(), CheckFpZone(), FOOTPRINT::GetAttributes(), FOOTPRINT::GetDescription(), FOOTPRINT::GetFlag(), FOOTPRINT::GetKeywords(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), FOOTPRINT::GetReference(), FOOTPRINT::GetTypeName(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), FOOTPRINT::Groups(), FOOTPRINT::Models(), FOOTPRINT::Pads(), PCB_FP_SHAPE_T, PCB_FP_TEXT_T, text, EDA_ITEM::Type(), and FOOTPRINT::Zones().

Referenced by BOOST_AUTO_TEST_CASE().

◆ CheckFpPad()

void KI_TEST::CheckFpPad ( const PAD expected,
const PAD pad 
)

Definition at line 247 of file board_test_utils.cpp.

248{
249 BOOST_TEST_CONTEXT( "Assert PAD with KIID=" << expected->m_Uuid.AsString() )
250 {
251 CHECK_ENUM_CLASS_EQUAL( expected->Type(), pad->Type() );
252
253 BOOST_CHECK_EQUAL( expected->GetNumber(), pad->GetNumber() );
254 CHECK_ENUM_CLASS_EQUAL( expected->GetAttribute(), pad->GetAttribute() );
255 CHECK_ENUM_CLASS_EQUAL( expected->GetProperty(), pad->GetProperty() );
256 CHECK_ENUM_CLASS_EQUAL( expected->GetShape(), pad->GetShape() );
257
258 BOOST_CHECK_EQUAL( expected->IsLocked(), pad->IsLocked() );
259
260 BOOST_CHECK_EQUAL( expected->GetPosition(), pad->GetPosition() );
261 BOOST_CHECK_EQUAL( expected->GetSize(), pad->GetSize() );
262 BOOST_CHECK_EQUAL( expected->GetOrientation(), pad->GetOrientation() );
263 BOOST_CHECK_EQUAL( expected->GetDelta(), pad->GetDelta() );
264 BOOST_CHECK_EQUAL( expected->GetOffset(), pad->GetOffset() );
265 BOOST_CHECK_EQUAL( expected->GetDrillSize(), pad->GetDrillSize() );
266 CHECK_ENUM_CLASS_EQUAL( expected->GetDrillShape(), pad->GetDrillShape() );
267
268 BOOST_CHECK_EQUAL( expected->GetLayerSet(), pad->GetLayerSet() );
269
270 BOOST_CHECK_EQUAL( expected->GetNetCode(), pad->GetNetCode() );
271 BOOST_CHECK_EQUAL( expected->GetPinFunction(), pad->GetPinFunction() );
272 BOOST_CHECK_EQUAL( expected->GetPinType(), pad->GetPinType() );
273 BOOST_CHECK_EQUAL( expected->GetPadToDieLength(), pad->GetPadToDieLength() );
274 BOOST_CHECK_EQUAL( expected->GetLocalSolderMaskMargin(), pad->GetLocalSolderMaskMargin() );
275 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMargin(),
276 pad->GetLocalSolderPasteMargin() );
277 BOOST_CHECK_EQUAL( expected->GetLocalSolderPasteMarginRatio(),
278 pad->GetLocalSolderPasteMarginRatio() );
279 BOOST_CHECK_EQUAL( expected->GetLocalClearance(), pad->GetLocalClearance() );
280 CHECK_ENUM_CLASS_EQUAL( expected->GetZoneConnection(), pad->GetZoneConnection() );
281 BOOST_CHECK_EQUAL( expected->GetThermalSpokeWidth(), pad->GetThermalSpokeWidth() );
282 BOOST_CHECK_EQUAL( expected->GetThermalSpokeAngle(), pad->GetThermalSpokeAngle() );
283 BOOST_CHECK_EQUAL( expected->GetThermalGap(), pad->GetThermalGap() );
284 BOOST_CHECK_EQUAL( expected->GetRoundRectRadiusRatio(), pad->GetRoundRectRadiusRatio() );
285 BOOST_CHECK_EQUAL( expected->GetChamferRectRatio(), pad->GetChamferRectRatio() );
286 BOOST_CHECK_EQUAL( expected->GetChamferPositions(), pad->GetChamferPositions() );
287 BOOST_CHECK_EQUAL( expected->GetRemoveUnconnected(), pad->GetRemoveUnconnected() );
288 BOOST_CHECK_EQUAL( expected->GetKeepTopBottom(), pad->GetKeepTopBottom() );
289
290 // TODO: check complex pad shapes
291 CHECK_ENUM_CLASS_EQUAL( expected->GetAnchorPadShape(), pad->GetAnchorPadShape() );
293 pad->GetCustomShapeInZoneOpt() );
294 }
295}
const KIID m_Uuid
Definition: eda_item.h:506
wxString AsString() const
Definition: kiid.cpp:249
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:777
PAD_PROP GetProperty() const
Definition: pad.h:397
bool GetRemoveUnconnected() const
Definition: pad.h:590
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:377
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:391
const wxString & GetPinType() const
Definition: pad.h:151
const VECTOR2I & GetDrillSize() const
Definition: pad.h:261
PAD_ATTRIB GetAttribute() const
Definition: pad.h:394
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:503
const wxString & GetPinFunction() const
Definition: pad.h:145
const wxString & GetNumber() const
Definition: pad.h:134
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:419
bool IsLocked() const override
Definition: pad.cpp:151
VECTOR2I GetPosition() const override
Definition: pad.h:196
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:522
const VECTOR2I & GetOffset() const
Definition: pad.h:268
int GetLocalSolderMaskMargin() const
Definition: pad.h:409
bool GetKeepTopBottom() const
Definition: pad.h:596
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:206
const VECTOR2I & GetDelta() const
Definition: pad.h:258
PAD_SHAPE GetShape() const
Definition: pad.h:188
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:364
int GetThermalSpokeWidth() const
Definition: pad.h:512
int GetLocalSolderPasteMargin() const
Definition: pad.h:416
int GetChamferPositions() const
Definition: pad.h:575
double GetRoundRectRadiusRatio() const
Definition: pad.h:556
int GetThermalGap() const
Definition: pad.h:535
const VECTOR2I & GetSize() const
Definition: pad.h:251
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:201
double GetChamferRectRatio() const
Definition: pad.h:565
int GetPadToDieLength() const
Definition: pad.h:407
#define BOOST_TEST_CONTEXT(A)

References KIID::AsString(), BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, PAD::GetAnchorPadShape(), PAD::GetAttribute(), PAD::GetChamferPositions(), PAD::GetChamferRectRatio(), PAD::GetCustomShapeInZoneOpt(), PAD::GetDelta(), PAD::GetDrillShape(), PAD::GetDrillSize(), PAD::GetKeepTopBottom(), PAD::GetLayerSet(), PAD::GetLocalClearance(), PAD::GetLocalSolderMaskMargin(), PAD::GetLocalSolderPasteMargin(), PAD::GetLocalSolderPasteMarginRatio(), BOARD_CONNECTED_ITEM::GetNetCode(), PAD::GetNumber(), PAD::GetOffset(), PAD::GetOrientation(), PAD::GetPadToDieLength(), PAD::GetPinFunction(), PAD::GetPinType(), PAD::GetPosition(), PAD::GetProperty(), PAD::GetRemoveUnconnected(), PAD::GetRoundRectRadiusRatio(), PAD::GetShape(), PAD::GetSize(), PAD::GetThermalGap(), PAD::GetThermalSpokeAngle(), PAD::GetThermalSpokeWidth(), PAD::GetZoneConnection(), PAD::IsLocked(), EDA_ITEM::m_Uuid, pad, and EDA_ITEM::Type().

Referenced by CheckFootprint().

◆ CheckFpShape()

void KI_TEST::CheckFpShape ( const FP_SHAPE expected,
const FP_SHAPE shape 
)

Definition at line 332 of file board_test_utils.cpp.

333{
334 BOOST_TEST_CONTEXT( "Assert FP_SHAPE with KIID=" << expected->m_Uuid.AsString() )
335 {
336 CHECK_ENUM_CLASS_EQUAL( expected->Type(), shape->Type() );
337
338 CHECK_ENUM_CLASS_EQUAL( expected->GetShape(), shape->GetShape() );
339
340 BOOST_CHECK_EQUAL( expected->IsLocked(), shape->IsLocked() );
341
342 BOOST_CHECK_EQUAL( expected->GetStart(), shape->GetStart() );
343 BOOST_CHECK_EQUAL( expected->GetEnd(), shape->GetEnd() );
344 if( expected->GetShape() == SHAPE_T::ARC )
345 {
346 // center and position might differ as they are calculated from start/mid/end -> compare mid instead
347 BOOST_CHECK_EQUAL( expected->GetArcMid(), shape->GetArcMid() );
348 }
349 else
350 {
351 BOOST_CHECK_EQUAL( expected->GetCenter(), shape->GetCenter() );
352 BOOST_CHECK_EQUAL( expected->GetPosition(), shape->GetPosition() );
353 }
354 BOOST_CHECK_EQUAL( expected->GetBezierC1(), shape->GetBezierC1() );
355 BOOST_CHECK_EQUAL( expected->GetBezierC2(), shape->GetBezierC2() );
356
357 CheckShapePolySet( &expected->GetPolyShape(), &shape->GetPolyShape() );
358
359 BOOST_CHECK_EQUAL( expected->GetLayerSet(), shape->GetLayerSet() );
360
361 BOOST_CHECK_EQUAL( expected->GetStroke().GetWidth(), shape->GetStroke().GetWidth() );
363 shape->GetStroke().GetPlotStyle() );
364 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), shape->GetFillMode() );
365 }
366}
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:174
virtual bool IsLocked() const
Definition: board_item.cpp:65
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:176
FILL_T GetFillMode() const
Definition: eda_shape.h:102
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:244
SHAPE_T GetShape() const
Definition: eda_shape.h:112
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:142
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:117
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:173
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:441
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:65
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:69
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:63
int GetWidth() const
Definition: stroke_params.h:98
PLOT_DASH_TYPE GetPlotStyle() const
void CheckShapePolySet(const SHAPE_POLY_SET *expected, const SHAPE_POLY_SET *polyset)

References ARC, KIID::AsString(), BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, CheckShapePolySet(), EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetFillMode(), BOARD_ITEM::GetLayerSet(), STROKE_PARAMS::GetPlotStyle(), EDA_SHAPE::GetPolyShape(), PCB_SHAPE::GetPosition(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), PCB_SHAPE::GetStroke(), STROKE_PARAMS::GetWidth(), BOARD_ITEM::IsLocked(), EDA_ITEM::m_Uuid, and EDA_ITEM::Type().

Referenced by CheckFootprint().

◆ CheckFpText()

void KI_TEST::CheckFpText ( const FP_TEXT expected,
const FP_TEXT text 
)

Definition at line 298 of file board_test_utils.cpp.

299{
300 BOOST_TEST_CONTEXT( "Assert FP_TEXT with KIID=" << expected->m_Uuid.AsString() )
301 {
302 CHECK_ENUM_CLASS_EQUAL( expected->Type(), text->Type() );
303
304 CHECK_ENUM_CLASS_EQUAL( expected->GetType(), text->GetType() );
305
306 BOOST_CHECK_EQUAL( expected->IsLocked(), text->IsLocked() );
307
308 BOOST_CHECK_EQUAL( expected->GetText(), text->GetText() );
309 BOOST_CHECK_EQUAL( expected->GetPosition(), text->GetPosition() );
310 BOOST_CHECK_EQUAL( expected->GetTextAngle(), text->GetTextAngle() );
311 BOOST_CHECK_EQUAL( expected->IsKeepUpright(), text->IsKeepUpright() );
312
313 BOOST_CHECK_EQUAL( expected->GetLayerSet(), text->GetLayerSet() );
314 BOOST_CHECK_EQUAL( expected->IsVisible(), text->IsVisible() );
315
316 BOOST_CHECK_EQUAL( expected->GetTextSize(), text->GetTextSize() );
317 BOOST_CHECK_EQUAL( expected->GetLineSpacing(), text->GetLineSpacing() );
318 BOOST_CHECK_EQUAL( expected->GetTextThickness(), text->GetTextThickness() );
319 BOOST_CHECK_EQUAL( expected->IsBold(), text->IsBold() );
320 BOOST_CHECK_EQUAL( expected->IsItalic(), text->IsItalic() );
321 BOOST_CHECK_EQUAL( expected->GetHorizJustify(), text->GetHorizJustify() );
322 BOOST_CHECK_EQUAL( expected->GetVertJustify(), text->GetVertJustify() );
323 BOOST_CHECK_EQUAL( expected->IsMirrored(), text->IsMirrored() );
324 BOOST_CHECK_EQUAL( expected->GetFontName(),
325 text->GetFontName() ); // TODO: bold/italic setting?
326
327 // TODO: render cache?
328 }
329}
wxString GetFontName() const
Definition: eda_text.cpp:751
bool IsItalic() const
Definition: eda_text.h:120
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:117
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
bool IsKeepUpright() const
Definition: eda_text.h:145
virtual bool IsVisible() const
Definition: eda_text.h:126
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:139
double GetLineSpacing() const
Definition: eda_text.h:183
bool IsMirrored() const
Definition: eda_text.h:129
bool IsBold() const
Definition: eda_text.h:123
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:142
int GetTextThickness() const
Definition: eda_text.h:109
VECTOR2I GetTextSize() const
Definition: eda_text.h:186
virtual VECTOR2I GetPosition() const override
Definition: fp_text.h:87
TEXT_TYPE GetType() const
Definition: fp_text.h:120

References KIID::AsString(), BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, EDA_TEXT::GetFontName(), EDA_TEXT::GetHorizJustify(), BOARD_ITEM::GetLayerSet(), EDA_TEXT::GetLineSpacing(), FP_TEXT::GetPosition(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetTextThickness(), FP_TEXT::GetType(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsKeepUpright(), BOARD_ITEM::IsLocked(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), EDA_ITEM::m_Uuid, text, and EDA_ITEM::Type().

Referenced by CheckFootprint().

◆ CheckFpZone()

void KI_TEST::CheckFpZone ( const FP_ZONE expected,
const FP_ZONE zone 
)

Definition at line 369 of file board_test_utils.cpp.

370{
371 BOOST_TEST_CONTEXT( "Assert FP_ZONE with KIID=" << expected->m_Uuid.AsString() )
372 {
373 CHECK_ENUM_CLASS_EQUAL( expected->Type(), zone->Type() );
374
375 BOOST_CHECK_EQUAL( expected->IsLocked(), zone->IsLocked() );
376
377 BOOST_CHECK_EQUAL( expected->GetNetCode(), zone->GetNetCode() );
378 BOOST_CHECK_EQUAL( expected->GetAssignedPriority(), zone->GetAssignedPriority() );
380 BOOST_CHECK_EQUAL( expected->GetLocalClearance(), zone->GetLocalClearance() );
381 BOOST_CHECK_EQUAL( expected->GetMinThickness(), zone->GetMinThickness() );
382
383 BOOST_CHECK_EQUAL( expected->GetLayerSet(), zone->GetLayerSet() );
384
385 BOOST_CHECK_EQUAL( expected->IsFilled(), zone->IsFilled() );
386 CHECK_ENUM_CLASS_EQUAL( expected->GetFillMode(), zone->GetFillMode() );
387 BOOST_CHECK_EQUAL( expected->GetHatchThickness(), zone->GetHatchThickness() );
388 BOOST_CHECK_EQUAL( expected->GetHatchGap(), zone->GetHatchGap() );
389 BOOST_CHECK_EQUAL( expected->GetHatchOrientation(), zone->GetHatchOrientation() );
390 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingLevel(), zone->GetHatchSmoothingLevel() );
391 BOOST_CHECK_EQUAL( expected->GetHatchSmoothingValue(), zone->GetHatchSmoothingValue() );
392 BOOST_CHECK_EQUAL( expected->GetHatchBorderAlgorithm(), zone->GetHatchBorderAlgorithm() );
393 BOOST_CHECK_EQUAL( expected->GetHatchHoleMinArea(), zone->GetHatchHoleMinArea() );
394 BOOST_CHECK_EQUAL( expected->GetThermalReliefGap(), zone->GetThermalReliefGap() );
395 BOOST_CHECK_EQUAL( expected->GetThermalReliefSpokeWidth(),
397 BOOST_CHECK_EQUAL( expected->GetCornerSmoothingType(), zone->GetCornerSmoothingType() );
398 BOOST_CHECK_EQUAL( expected->GetCornerRadius(), zone->GetCornerRadius() );
400 BOOST_CHECK_EQUAL( expected->GetMinIslandArea(), zone->GetMinIslandArea() );
401
402 BOOST_CHECK_EQUAL( expected->GetIsRuleArea(), zone->GetIsRuleArea() );
403 BOOST_CHECK_EQUAL( expected->GetDoNotAllowCopperPour(), zone->GetDoNotAllowCopperPour() );
404 BOOST_CHECK_EQUAL( expected->GetDoNotAllowVias(), zone->GetDoNotAllowVias() );
405 BOOST_CHECK_EQUAL( expected->GetDoNotAllowTracks(), zone->GetDoNotAllowTracks() );
406 BOOST_CHECK_EQUAL( expected->GetDoNotAllowPads(), zone->GetDoNotAllowPads() );
407 BOOST_CHECK_EQUAL( expected->GetDoNotAllowFootprints(), zone->GetDoNotAllowFootprints() );
408
409 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
411 BOOST_CHECK_EQUAL( expected->GetZoneName(), zone->GetZoneName() );
412
413 CheckShapePolySet( expected->Outline(), zone->Outline() );
414 // TODO: filled zones
415 }
416}
int GetHatchBorderAlgorithm() const
Definition: zone.h:271
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:691
bool GetDoNotAllowVias() const
Definition: zone.h:693
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:705
bool GetDoNotAllowPads() const
Definition: zone.h:695
bool GetDoNotAllowTracks() const
Definition: zone.h:694
bool IsFilled() const
Definition: zone.h:235
SHAPE_POLY_SET * Outline()
Definition: zone.h:305
long long int GetMinIslandArea() const
Definition: zone.h:708
wxString GetZoneName() const
Definition: zone.h:117
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:425
int GetMinThickness() const
Definition: zone.h:244
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:241
int GetHatchThickness() const
Definition: zone.h:253
double GetHatchHoleMinArea() const
Definition: zone.h:268
int GetThermalReliefSpokeWidth() const
Definition: zone.h:188
EDA_ANGLE GetHatchOrientation() const
Definition: zone.h:259
bool GetDoNotAllowFootprints() const
Definition: zone.h:696
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:167
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:115
bool GetDoNotAllowCopperPour() const
Definition: zone.h:692
int GetHatchGap() const
Definition: zone.h:256
TEARDROP_TYPE GetTeardropAreaType() const
Definition: zone.h:686
double GetHatchSmoothingValue() const
Definition: zone.h:265
int GetHatchSmoothingLevel() const
Definition: zone.h:262
unsigned int GetCornerRadius() const
Definition: zone.h:646
int GetCornerSmoothingType() const
Definition: zone.h:642
int GetThermalReliefGap() const
Definition: zone.h:177
unsigned GetAssignedPriority() const
Definition: zone.h:106

References KIID::AsString(), BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, CheckShapePolySet(), ZONE::GetAssignedPriority(), ZONE::GetCornerRadius(), ZONE::GetCornerSmoothingType(), ZONE::GetDoNotAllowCopperPour(), ZONE::GetDoNotAllowFootprints(), ZONE::GetDoNotAllowPads(), ZONE::GetDoNotAllowTracks(), ZONE::GetDoNotAllowVias(), ZONE::GetFillMode(), ZONE::GetHatchBorderAlgorithm(), ZONE::GetHatchGap(), ZONE::GetHatchHoleMinArea(), ZONE::GetHatchOrientation(), ZONE::GetHatchSmoothingLevel(), ZONE::GetHatchSmoothingValue(), ZONE::GetHatchThickness(), ZONE::GetIslandRemovalMode(), ZONE::GetIsRuleArea(), ZONE::GetLayerSet(), ZONE::GetLocalClearance(), ZONE::GetMinIslandArea(), ZONE::GetMinThickness(), BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::GetPadConnection(), ZONE::GetTeardropAreaType(), ZONE::GetThermalReliefGap(), ZONE::GetThermalReliefSpokeWidth(), ZONE::GetZoneName(), ZONE::IsFilled(), BOARD_ITEM::IsLocked(), EDA_ITEM::m_Uuid, ZONE::Outline(), and EDA_ITEM::Type().

Referenced by CheckFootprint().

◆ CheckShapePolySet()

void KI_TEST::CheckShapePolySet ( const SHAPE_POLY_SET expected,
const SHAPE_POLY_SET polyset 
)

Definition at line 419 of file board_test_utils.cpp.

420{
421 BOOST_TEST_CONTEXT( "Assert SHAPE_POLY_SET" )
422 {
423 BOOST_CHECK_EQUAL( expected->OutlineCount(), polyset->OutlineCount() );
424 BOOST_CHECK_EQUAL( expected->TotalVertices(), polyset->TotalVertices() );
425
426 // TODO: check all outlines and holes
427 }
428}
int TotalVertices() const
Delete aIdx-th polygon from the set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.

References BOOST_TEST_CONTEXT, SHAPE_POLY_SET::OutlineCount(), and SHAPE_POLY_SET::TotalVertices().

Referenced by CheckFpShape(), and CheckFpZone().

◆ CheckUnorderedMatches()

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.

This means that:

  • Every "expected" object is "found"
  • Every "found" object is "expected"

This is a very generic function: all you need are two containers of any type and a function to check if a given "found" object corresponds to a given "expected object". Conditions:

  • The expected object type needs operator<< (for logging)
  • The expected object container does not contain multiple references to the same object.
  • Identical values are also can't be present as the predicate can't tell which one to match up.

Not needed:

  • Equality or ordering operators

This is a slightly more complex way of doing it that, say, sorting both lists and checking element-by-element matches. However, it can tell you exactly which objects are problematic, as well as a simple go/no-go.

When you have two containers of identical types (or you have a suitable operator==) and ordering is important, you can use BOOST_CHECK_EQUAL_COLLECTIONS

Parameters
aExpecteda container of "expected" items, usually from a test case
aMatcheda container of "found" items, usually the result of some routine under test
aMatchPredicatea predicate that determines if a given "found" object matches a given "expected" object.

Definition at line 235 of file unit_test_utils.h.

237{
238 using EXP_OBJ = typename EXP_CONT::value_type;
239
240 // set of object we've already found
241 std::set<const EXP_OBJ*> matched;
242
243 // fill the set of object that match
244 for( const auto& found : aFound )
245 {
246 for( const auto& expected : aExpected )
247 {
248 if( aMatchPredicate( expected, found ) )
249 {
250 matched.insert( &expected );
251 break;
252 }
253 }
254 }
255
256 // first check every expected object was "found"
257 for( const EXP_OBJ& exp : aExpected )
258 {
259 BOOST_CHECK_MESSAGE( matched.count( &exp ) > 0, "Expected item was not found. Expected: \n"
260 << exp );
261 }
262
263 // check every "found" object was expected
264 for( const EXP_OBJ* found : matched )
265 {
266 const bool was_expected = std::find_if( aExpected.begin(), aExpected.end(),
267 [found]( const EXP_OBJ& aObj )
268 {
269 return &aObj == found;
270 } ) != aExpected.end();
271
272 BOOST_CHECK_MESSAGE( was_expected, "Found item was not expected. Found: \n" << *found );
273 }
274}
typename EXP_CONT::value_type EXP_OBJ

Referenced by BOOST_AUTO_TEST_CASE(), CheckCollisionsMatchExpected(), and CheckInvalidsMatchExpected().

◆ CollectionHasNoDuplicates()

template<typename T >
bool KI_TEST::CollectionHasNoDuplicates ( const T &  aCollection)

Predicate to check a collection has no duplicate elements.

Definition at line 281 of file unit_test_utils.h.

282{
283 T sorted = aCollection;
284 std::sort( sorted.begin(), sorted.end() );
285
286 return std::adjacent_find( sorted.begin(), sorted.end() ) == sorted.end();
287}

Referenced by BOOST_AUTO_TEST_CASE().

◆ DrawArc()

void KI_TEST::DrawArc ( FOOTPRINT aFootprint,
const VECTOR2I aCentre,
const VECTOR2I aStart,
const EDA_ANGLE aAngle,
int  aWidth,
PCB_LAYER_ID  aLayer 
)

Draw an arc on a footprint.

Parameters
aModThe footprint to add the segment to
aCentreThe arc centre
aStartThe arc start point
aAngleThe arc angle
aWidthThe width of the arc segment
aLayerThe layer to draw on

Definition at line 59 of file board_construction_utils.cpp.

61{
62 std::unique_ptr<FP_SHAPE> arc = std::make_unique<FP_SHAPE>( &aFootprint, SHAPE_T::ARC );
63
64 arc->SetCenter0( aCentre );
65 arc->SetStart0( aStart );
66 arc->SetArcAngleAndEnd0( aAngle );
67
68 arc->SetStroke( STROKE_PARAMS( aWidth, PLOT_DASH_TYPE::SOLID ) );
69 arc->SetLayer( aLayer );
70
71 aFootprint.Add( arc.release() );
72}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:549
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88

References FOOTPRINT::Add(), ARC, and SOLID.

Referenced by DrawRect().

◆ DrawPolyline()

void KI_TEST::DrawPolyline ( FOOTPRINT aFootprint,
const std::vector< VECTOR2I > &  aPts,
int  aWidth,
PCB_LAYER_ID  aLayer 
)

Draw a polyline - a set of linked segments.

Parameters
aModThe footprint to add the segment to
aPtsThe polyline points
aWidthThe width of the segments
aLayerThe layer to draw on

Definition at line 49 of file board_construction_utils.cpp.

51{
52 for( unsigned i = 0; i < aPts.size() - 1; ++i )
53 {
54 DrawSegment( aFootprint, { aPts[i], aPts[i + 1] }, aWidth, aLayer );
55 }
56}
void DrawSegment(FOOTPRINT &aFootprint, const SEG &aSeg, int aWidth, PCB_LAYER_ID aLayer)
Draw a segment in the given footprint.

References DrawSegment().

◆ DrawRect()

void KI_TEST::DrawRect ( FOOTPRINT aFootprint,
const VECTOR2I aPos,
const VECTOR2I aSize,
int  aRadius,
int  aWidth,
PCB_LAYER_ID  aLayer 
)

Draw a rectangle on a footprint.

Parameters
aModThe footprint to add the rectangle to
aPosRectangle centre point
aSizeRectangle size (x, y)
aRadiusCorner radius (0 for a normal rect)
aWidthLine width
aLayerLayer to draw on

Definition at line 75 of file board_construction_utils.cpp.

77{
78 const auto x_r = aPos.x + aSize.x / 2;
79 const auto x_l = aPos.x - aSize.x / 2;
80 const auto y_t = aPos.y + aSize.y / 2;
81 const auto y_b = aPos.y - aSize.y / 2;
82
83 const auto xin_r = x_r - aRadius;
84 const auto xin_l = x_l + aRadius;
85 const auto yin_t = y_t - aRadius;
86 const auto yin_b = y_b + aRadius;
87
88 // If non-zero (could be zero if it's a stadium shape)
89 if( xin_l != xin_r )
90 {
91 DrawSegment( aFootprint, { { xin_l, y_t }, { xin_r, y_t } }, aWidth, aLayer );
92 DrawSegment( aFootprint, { { xin_l, y_b }, { xin_r, y_b } }, aWidth, aLayer );
93 }
94
95 if( yin_b != yin_t )
96 {
97 DrawSegment( aFootprint, { { x_l, yin_b }, { x_l, yin_t } }, aWidth, aLayer );
98 DrawSegment( aFootprint, { { x_r, yin_b }, { x_r, yin_t } }, aWidth, aLayer );
99 }
100
101 if( aRadius > 0 )
102 {
103 DrawArc( aFootprint, { xin_r, yin_t }, { x_r, yin_t }, ANGLE_90, aWidth, aLayer );
104 DrawArc( aFootprint, { xin_l, yin_t }, { xin_l, y_t }, ANGLE_90, aWidth, aLayer );
105 DrawArc( aFootprint, { xin_l, yin_b }, { x_l, yin_b }, ANGLE_90, aWidth, aLayer );
106 DrawArc( aFootprint, { xin_r, yin_b }, { xin_r, y_b }, ANGLE_90, aWidth, aLayer );
107 }
108}
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
void DrawArc(FOOTPRINT &aFootprint, const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aAngle, int aWidth, PCB_LAYER_ID aLayer)
Draw an arc on a footprint.

References ANGLE_90, DrawArc(), DrawSegment(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by AddRectCourtyard().

◆ DrawSegment()

void KI_TEST::DrawSegment ( FOOTPRINT aFootprint,
const SEG aSeg,
int  aWidth,
PCB_LAYER_ID  aLayer 
)

Draw a segment in the given footprint.

Parameters
aModThe footprint to add the segment to
aSegThe segment geometry
aWidthThe width of the segment
aLayerThe layer to draw on

Definition at line 35 of file board_construction_utils.cpp.

36{
37 std::unique_ptr<FP_SHAPE> seg = std::make_unique<FP_SHAPE>( &aFootprint, SHAPE_T::SEGMENT );
38
39 seg->SetStart0( aSeg.A );
40 seg->SetEnd0( aSeg.B );
41
42 seg->SetStroke( STROKE_PARAMS( aWidth, PLOT_DASH_TYPE::SOLID ) );
43 seg->SetLayer( aLayer );
44
45 aFootprint.Add( seg.release() );
46}
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

References SEG::A, FOOTPRINT::Add(), SEG::B, SEGMENT, and SOLID.

Referenced by DrawPolyline(), DrawRect(), and MakeInvalidCourtyardTestFP().

◆ DumpBoardToFile()

void KI_TEST::DumpBoardToFile ( BOARD aBoard,
const std::string &  aFilename 
)

Utility function to simply write a Board out to a file.

Helps debug tests and utility programs by making it easy to quickly write to disk without directly using the PCB_PLUGIN API.

Note: The aBoard param is non-const because PCB_PLUGIN::Save demands it and I am not confident a const_cast will be a true assurance.

Parameters
aBoardthe board to write out
aFilenamethe filename to write to

Definition at line 65 of file board_file_utils.cpp.

66{
67 PCB_PLUGIN io;
68 io.Save( aFilename, &board );
69}
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:169
void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
Definition: pcb_plugin.cpp:342

References PCB_PLUGIN::Save().

Referenced by BOOST_FIXTURE_TEST_CASE(), KI_TEST::BOARD_DUMPER::DumpBoardToFile(), and testSaveLoad().

◆ DumpSchematicToFile()

void KI_TEST::DumpSchematicToFile ( SCHEMATIC aSchematic,
SCH_SHEET aSheet,
const std::string &  aFilename 
)

Definition at line 67 of file schematic_file_util.cpp.

68{
70 io.Save( aFilename, &aSheet, &aSchematic );
71}
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
void Save(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about,...

References SCH_SEXPR_PLUGIN::Save().

◆ FieldNameIdMatches()

bool KI_TEST::FieldNameIdMatches ( const LIB_FIELD aField,
const std::string &  aExpectedName,
int  aExpectedId 
)

Predicate to check a field name is as expected.

Parameters
aFieldLIB_FIELD to check the name
aExpectedNamethe expected field name
aExpectedIdthe expected field id
Returns
true if match

Definition at line 70 of file lib_field_test_utils.h.

72{
73 bool ok = true;
74 const auto gotName = aField.GetCanonicalName();
75
76 if( gotName != aExpectedName )
77 {
78 BOOST_TEST_INFO( "Field name: got '" << gotName << "', expected '" << aExpectedName );
79 ok = false;
80 }
81
82 const int gotId = aField.GetId();
83
84 if( gotId != aExpectedId )
85 {
86 BOOST_TEST_INFO( "Field ID: got '" << gotId << "', expected '" << aExpectedId );
87 ok = false;
88 }
89
90 return ok;
91}
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: lib_field.cpp:468
int GetId() const
Definition: lib_field.h:115

References BOOST_TEST_INFO, LIB_FIELD::GetCanonicalName(), and LIB_FIELD::GetId().

Referenced by AreDefaultFieldsCorrect(), and BOOST_AUTO_TEST_CASE().

◆ FillZones()

void KI_TEST::FillZones ( BOARD m_board)

Definition at line 108 of file board_test_utils.cpp.

109{
110 TOOL_MANAGER toolMgr;
111 toolMgr.SetEnvironment( m_board, nullptr, nullptr, nullptr, nullptr );
112
113 BOARD_COMMIT commit( &toolMgr );
114 ZONE_FILLER filler( m_board, &commit );
115 std::vector<ZONE*> toFill;
116
117 for( ZONE* zone : m_board->Zones() )
118 toFill.push_back( zone );
119
120 if( filler.Fill( toFill, false, nullptr ) )
121 commit.Push( _( "Fill Zone(s)" ), SKIP_UNDO | SKIP_SET_DIRTY | ZONE_FILL_OP );
122}
#define SKIP_SET_DIRTY
Definition: board_commit.h:41
#define SKIP_UNDO
Definition: board_commit.h:39
#define ZONE_FILL_OP
Definition: board_commit.h:43
ZONES & Zones()
Definition: board.h:313
Master controller class:
Definition: tool_manager.h:55
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
#define _(s)

References _, ZONE_FILLER::Fill(), BOARD_COMMIT::Push(), TOOL_MANAGER::SetEnvironment(), SKIP_SET_DIRTY, SKIP_UNDO, ZONE_FILL_OP, and BOARD::Zones().

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ getDebugType()

std::string KI_TEST::getDebugType ( SEXPR::SEXPR_TYPE  aType)
inline

Get a debug-friendly string for a given s-expr type.

Definition at line 57 of file sexpr_test_utils.h.

58{
59 switch( aType )
60 {
62 return "List";
64 return "Symbol";
66 return "String";
68 return "Double";
70 return "Integer";
71 }
72
73 return "<Unknown S-Expression Type!>";
74}

References SEXPR::SEXPR_TYPE_ATOM_DOUBLE, SEXPR::SEXPR_TYPE_ATOM_INTEGER, SEXPR::SEXPR_TYPE_ATOM_STRING, SEXPR::SEXPR_TYPE_ATOM_SYMBOL, and SEXPR::SEXPR_TYPE_LIST.

Referenced by GetSexprDebugType(), and IsSexprOfType().

◆ getEeschemaTestDataDir()

std::string KI_TEST::getEeschemaTestDataDir ( )

Definition at line 44 of file schematic_file_util.cpp.

45{
46 const char* env = std::getenv( "KICAD_TEST_EESCHEMA_DATA_DIR" );
47 std::string fn;
48
49 if( !env )
50 {
51 // Use the compiled-in location of the data dir (i.e. where the files were at build time)
53 }
54 else
55 {
56 // Use whatever was given in the env var
57 fn = env;
58 }
59
60 // Ensure the string ends in / to force a directory interpretation
61 fn += "/";
62
63 return fn;
64}
#define QA_EESCHEMA_DATA_LOCATION

References QA_EESCHEMA_DATA_LOCATION.

Referenced by LoadSchematic().

◆ GetEeschemaTestDataDir()

wxFileName KI_TEST::GetEeschemaTestDataDir ( )

Get the configured location of Eeschema test data.

By default, this is the test data in the source tree, but can be overridden by the KICAD_TEST_EESCHEMA_DATA_DIR environment variable.

Returns
a filename referring to the test data dir to use.

Definition at line 41 of file eeschema_test_utils.cpp.

42{
43 const char* env = std::getenv( "KICAD_TEST_EESCHEMA_DATA_DIR" );
44 wxString fn;
45
46 if( !env )
47 {
48 // Use the compiled-in location of the data dir
49 // (i.e. where the files were at build time)
51 }
52 else
53 {
54 // Use whatever was given in the env var
55 fn << env;
56 }
57
58 // Ensure the string ends in / to force a directory interpretation
59 fn << "/";
60
61 return wxFileName{ fn };
62}
#define QA_EESCHEMA_DATA_LOCATION

References QA_EESCHEMA_DATA_LOCATION.

Referenced by getEagleTestSchematic(), TEST_SIM_LIBRARY_SPICE_FIXTURE::GetLibraryPath(), KI_TEST::SCHEMATIC_TEST_FIXTURE::GetSchematicPath(), and TEST_SCH_SHEET_LIST_FIXTURE::GetSchematicPath().

◆ GetPcbnewTestDataDir()

std::string KI_TEST::GetPcbnewTestDataDir ( )

Utility which returns a path to the data directory where the test board files are stored.

Definition at line 42 of file board_file_utils.cpp.

43{
44 const char* env = std::getenv( "KICAD_TEST_PCBNEW_DATA_DIR" );
45 std::string fn;
46
47 if( !env )
48 {
49 // Use the compiled-in location of the data dir (i.e. where the files were at build time)
51 }
52 else
53 {
54 // Use whatever was given in the env var
55 fn = env;
56 }
57
58 // Ensure the string ends in / to force a directory interpretation
59 fn += "/";
60
61 return fn;
62}
#define QA_PCBNEW_DATA_LOCATION

References QA_PCBNEW_DATA_LOCATION.

Referenced by BOOST_AUTO_TEST_CASE(), and LoadBoard().

◆ GetSexprDebugType()

std::string KI_TEST::GetSexprDebugType ( const SEXPR::SEXPR aSexpr)
inline

Definition at line 76 of file sexpr_test_utils.h.

77{
78 return getDebugType( getType( aSexpr ) );
79}
std::string getDebugType(SEXPR::SEXPR_TYPE aType)
Get a debug-friendly string for a given s-expr type.
SEXPR::SEXPR_TYPE getType(const SEXPR::SEXPR &aSexpr)
Get the type of the s-expression.

References getDebugType(), and getType().

Referenced by BOOST_TEST_PRINT_NAMESPACE_OPEN::print_log_value< SEXPR::SEXPR >::operator()().

◆ getType()

SEXPR::SEXPR_TYPE KI_TEST::getType ( const SEXPR::SEXPR aSexpr)
inline

Get the type of the s-expression.

Definition at line 38 of file sexpr_test_utils.h.

39{
40 if( aSexpr.IsList() )
42 else if( aSexpr.IsSymbol() )
44 else if( aSexpr.IsString() )
46 else if( aSexpr.IsDouble() )
48 else if( aSexpr.IsInteger() )
50
51 throw( std::invalid_argument( "<Unknown S-Expression Type!>" ) );
52}
bool IsInteger() const
Definition: sexpr.h:53
bool IsString() const
Definition: sexpr.h:51
bool IsList() const
Definition: sexpr.h:49
bool IsDouble() const
Definition: sexpr.h:52
bool IsSymbol() const
Definition: sexpr.h:50

References SEXPR::SEXPR::IsDouble(), SEXPR::SEXPR::IsInteger(), SEXPR::SEXPR::IsList(), SEXPR::SEXPR::IsString(), SEXPR::SEXPR::IsSymbol(), SEXPR::SEXPR_TYPE_ATOM_DOUBLE, SEXPR::SEXPR_TYPE_ATOM_INTEGER, SEXPR::SEXPR_TYPE_ATOM_STRING, SEXPR::SEXPR_TYPE_ATOM_SYMBOL, and SEXPR::SEXPR_TYPE_LIST.

Referenced by GetSexprDebugType(), and IsSexprOfType().

◆ IsBoxWithinTol()

template<typename BOX >
bool KI_TEST::IsBoxWithinTol ( const BOX &  aBox,
const BOX &  aExp,
typename BOX::coord_type  aTol 
)

Check that a box is close enough to another box.

Definition at line 62 of file geometry.h.

63{
65 return IsVecWithinTol<VEC>( aBox.GetPosition(), aExp.GetPosition(), aTol )
66 && IsVecWithinTol<VEC>( aBox.GetSize(), aExp.GetSize(), aTol * 2 );
67}
Define a general 2D-vector/point.
Definition: vector2d.h:74

◆ IsColorNear()

bool KI_TEST::IsColorNear ( const KIGFX::COLOR4D aCol,
const KIGFX::COLOR4D  aOther,
double  aTol 
)
inline

Checks if a COLOR4D is close enough to another.

Definition at line 41 of file color4d_test_utils.h.

42{
43 return KI_TEST::IsWithin<double>( aCol.r, aOther.r, aTol )
44 && KI_TEST::IsWithin<double>( aCol.g, aOther.g, aTol )
45 && KI_TEST::IsWithin<double>( aCol.b, aOther.b, aTol )
46 && KI_TEST::IsWithin<double>( aCol.a, aOther.a, aTol );
47}
double r
Red component.
Definition: color4d.h:384
double g
Green component.
Definition: color4d.h:385
double a
Alpha component.
Definition: color4d.h:387
double b
Blue component.
Definition: color4d.h:386

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, and KIGFX::COLOR4D::r.

◆ IsColorNearHex()

bool KI_TEST::IsColorNearHex ( const KIGFX::COLOR4D aCol,
unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a 
)
inline

Checks if a COLOR4D is close enough to a given RGB char value.

Definition at line 52 of file color4d_test_utils.h.

54{
55 const double tol = 0.5 / 255.0; // One bit of quantised error
56
57 return KI_TEST::IsWithin<double>( aCol.r, r / 255.0, tol )
58 && KI_TEST::IsWithin<double>( aCol.g, g / 255.0, tol )
59 && KI_TEST::IsWithin<double>( aCol.b, b / 255.0, tol )
60 && KI_TEST::IsWithin<double>( aCol.a, a / 255.0, tol );
61}
E_SERIE r
Definition: eserie.cpp:41

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, KIGFX::COLOR4D::r, and r.

Referenced by BOOST_AUTO_TEST_CASE(), and IsImagePixelOfColor().

◆ IsDrcMarkerOfType()

bool KI_TEST::IsDrcMarkerOfType ( const PCB_MARKER aMarker,
int  aErrorCode 
)

Predicate for testing the type of a DRC marker.

Parameters
aMarkerthe marker to test
aErrorCodethe expected DRC violation code
Returns
true if the marker has this code

Definition at line 41 of file drc_test_utils.cpp.

42{
43 return aMarker.GetRCItem()->GetErrorCode() == aErrorCode;
44}
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:105

References MARKER_BASE::GetRCItem().

Referenced by CheckCollisionsMatchExpected().

◆ IsImagePixelOfColor()

bool KI_TEST::IsImagePixelOfColor ( const wxImage &  aImage,
int  aX,
int  aY,
const KIGFX::COLOR4D aColor 
)

Predicate to check an image pixel matches color and alpha.

Parameters
aImagethe image to check
aXpixel x-coordinate
aYpixel y-coordinate
aColorexpected color (alpha is 1.0 if image doesn't support alpha)
Returns
true if colour match

Definition at line 40 of file wximage_test_utils.cpp.

41{
42 const wxSize imageSize = aImage.GetSize();
43
44 if( imageSize.x < aX || imageSize.y < aY )
45 {
46 BOOST_TEST_INFO( "Pixel (" << aX << ", " << aY << "is not in image of size (" << imageSize.x
47 << ", " << imageSize.y << ")" );
48 return false;
49 }
50
51 const int r = aImage.GetRed( aX, aY );
52 const int g = aImage.GetGreen( aX, aY );
53 const int b = aImage.GetBlue( aX, aY );
54
55 const int a = aImage.HasAlpha() ? aImage.GetAlpha( aX, aY ) : 255;
56
57 if( !KI_TEST::IsColorNearHex( aColor, r, g, b, a ) )
58 {
59 BOOST_TEST_INFO( "Colour doesn't match: got rgba(" << r << ", " << g << ", " << b << ", "
60 << a << "), expected " << aColor );
61 return false;
62 }
63
64 return true;
65}
bool IsColorNearHex(const KIGFX::COLOR4D &aCol, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Checks if a COLOR4D is close enough to a given RGB char value.

References BOOST_TEST_INFO, IsColorNearHex(), and r.

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsSexprOfType()

bool KI_TEST::IsSexprOfType ( const SEXPR::SEXPR aSexpr,
SEXPR::SEXPR_TYPE  aType 
)
inline

Definition at line 81 of file sexpr_test_utils.h.

82{
83 if( getType( aSexpr ) != aType )
84 {
85 BOOST_TEST_MESSAGE( "Sexpr is not of type: " << getDebugType( aType ) );
86 return false;
87 }
88
89 return true;
90}

References getDebugType(), and getType().

Referenced by SexprIsDouble(), SexprIsDoubleWithValue(), SexprIsInteger(), SexprIsIntegerWithValue(), SexprIsList(), SexprIsListOfLength(), SexprIsString(), SexprIsStringWithValue(), SexprIsSymbol(), and SexprIsSymbolWithValue().

◆ IsSexprValueEqual()

template<typename VAL_T >
bool KI_TEST::IsSexprValueEqual ( const VAL_T &  aGot,
const VAL_T &  aExpected 
)

Predicate to check two s-expr values (of the same type) are equal.

Returns
false if not equal (and output logging)

Definition at line 98 of file sexpr_test_utils.h.

99{
100 if( aGot != aExpected )
101 {
102 BOOST_TEST_MESSAGE( "Sexpr value not equal: got " << aGot << ", expected " << aExpected );
103 return false;
104 }
105
106 return true;
107}

Referenced by SexprIsDoubleWithValue(), SexprIsIntegerWithValue(), SexprIsStringWithValue(), and SexprIsSymbolWithValue().

◆ IsUUID()

bool KI_TEST::IsUUID ( const std::string &  aStr)

Check if the string between the iterators looks like a UUID.

Definition at line 31 of file uuid_test_utils.cpp.

32{
33 std::regex uuid( "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" );
34 std::smatch match;
35
36 return std::regex_match( aStr, match, uuid );
37}

Referenced by IsUUIDPathWithLevels().

◆ IsUUIDPathWithLevels()

bool KI_TEST::IsUUIDPathWithLevels ( const std::string &  aStr,
unsigned  aLevels 
)

Predicate to check a string is a UUID path format.

Eg. levels=2: /1d33ca6f-67e8-41ae-a0aa-49d857ab38d5/1d33ca6f-67e8-41ae-a0aa-49d857ab38d5/

Parameters
aStrcandidate string
levelsexpected levels
Returns
true if format matches

Definition at line 40 of file uuid_test_utils.cpp.

41{
42 // A UUID is formatted as 8-4-4-4-12
43 const unsigned tsLen = 36;
44 const unsigned levelLen = tsLen + 1; // add the /
45
46 if( aStr.size() != aLevels * levelLen + 1 )
47 {
48 BOOST_TEST_INFO( "String is the wrong length for " << aLevels << " levels." );
49 return false;
50 }
51
52 if( aStr[0] != '/' )
53 {
54 BOOST_TEST_INFO( "Doesn't start with '/'" );
55 return false;
56 }
57
58 auto tsBegin = aStr.begin() + 1;
59
60 for( unsigned i = 0; i < aLevels; i++ )
61 {
62 if( !IsUUID( std::string( tsBegin, tsBegin + tsLen ) ) )
63 {
64 BOOST_TEST_INFO( "Not a UUID at level "
65 << i << ": " << std::string( tsBegin, tsBegin + tsLen ) );
66 return false;
67 }
68
69 if( *( tsBegin + tsLen ) != '/' )
70 {
71 BOOST_TEST_INFO( "level doesn't end in '/'" );
72 return false;
73 }
74
75 tsBegin += levelLen;
76 }
77
78 return true;
79}
bool IsUUID(const std::string &aStr)
Check if the string between the iterators looks like a UUID.

References BOOST_TEST_INFO, and IsUUID().

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsVecWithinTol()

template<typename VEC >
bool KI_TEST::IsVecWithinTol ( const VEC &  aVec,
const VEC &  aExp,
typename VEC::coord_type  aTol 
)

Check that both x and y of a vector are within expected error.

Definition at line 52 of file geometry.h.

53{
54 return IsWithin<typename VEC::coord_type>( aVec.x, aExp.x, aTol )
55 && IsWithin<typename VEC::coord_type>( aVec.y, aExp.y, aTol );
56}

◆ IsWithin()

template<typename T >
bool KI_TEST::IsWithin ( aValue,
aNominal,
aError 
)

Check if a value is within a tolerance of a nominal value.

Returns
value is in [aNominal - aError, aNominal + aError]

Definition at line 57 of file numeric.h.

58{
59 return ( aValue >= aNominal - aError ) && ( aValue <= aNominal + aError );
60}

Referenced by GEOM_TEST::ArePerpendicular(), and GEOM_TEST::IsPointAtDistance().

◆ IsWithinAndAbove()

template<typename T >
bool KI_TEST::IsWithinAndAbove ( aValue,
aNominal,
aErrorAbove 
)

value is in range [aNominal, aNominal + aErrorAbove]

Definition at line 84 of file numeric.h.

85{
86 return IsWithinBounds( aValue, aNominal, aErrorAbove, 0 );
87}
bool IsWithinBounds(T aValue, T aNominal, T aErrorAbove, T aErrorBelow)
Check if a value is within a tolerance of a nominal value, with different allowances for errors above...
Definition: numeric.h:68

References IsWithinBounds().

◆ IsWithinAndBelow()

template<typename T >
bool KI_TEST::IsWithinAndBelow ( aValue,
aNominal,
aErrorBelow 
)

value is in range [aNominal - aErrorBelow, aNominal]

Definition at line 76 of file numeric.h.

77{
78 return IsWithinBounds( aValue, aNominal, 0, aErrorBelow );
79}

References IsWithinBounds().

◆ IsWithinBounds()

template<typename T >
bool KI_TEST::IsWithinBounds ( aValue,
aNominal,
aErrorAbove,
aErrorBelow 
)

Check if a value is within a tolerance of a nominal value, with different allowances for errors above and below.

Returns
value is in [aNominal - aErrorBelow, aNominal + aErrorAbove]

Definition at line 68 of file numeric.h.

69{
70 return ( aValue >= aNominal - aErrorBelow ) && ( aValue <= aNominal + aErrorAbove );
71}

Referenced by IsWithinAndAbove(), and IsWithinAndBelow().

◆ IsWithinWrapped()

template<typename T >
bool KI_TEST::IsWithinWrapped ( aValue,
aNominal,
aWrap,
aError 
)

Check if a value is within a tolerance of a nominal value, wrapping to a given val.

Returns
value is in [( aNominal - aError ) % aWrap, ( aNominal + aError ) % aWrap]

Definition at line 42 of file numeric.h.

43{
44 double diff = std::fmod( aNominal - aValue + aWrap / 2.0, aWrap );
45
46 if( diff < 0 )
47 diff += aWrap;
48
49 return diff - aWrap / 2.0 <= aError;
50}

◆ LoadBoard()

void KI_TEST::LoadBoard ( SETTINGS_MANAGER aSettingsManager,
const wxString &  aRelPath,
std::unique_ptr< BOARD > &  aBoard 
)

Definition at line 70 of file board_test_utils.cpp.

72{
73 if( aBoard )
74 {
75 aBoard->SetProject( nullptr );
76 aBoard = nullptr;
77 }
78
79 std::string absPath = GetPcbnewTestDataDir() + aRelPath.ToStdString();
80 wxFileName projectFile( absPath + ".kicad_pro" );
81 wxFileName legacyProject( absPath + ".pro" );
82 std::string boardPath = absPath + ".kicad_pcb";
83 wxFileName rulesFile( absPath + ".kicad_dru" );
84
85 if( projectFile.Exists() )
86 aSettingsManager.LoadProject( projectFile.GetFullPath() );
87 else if( legacyProject.Exists() )
88 aSettingsManager.LoadProject( legacyProject.GetFullPath() );
89
90 aBoard = ReadBoardFromFileOrStream( boardPath );
91
92 if( projectFile.Exists() || legacyProject.Exists() )
93 aBoard->SetProject( &aSettingsManager.Prj() );
94
95 auto m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard.get(), &aBoard->GetDesignSettings() );
96
97 if( rulesFile.Exists() )
98 m_DRCEngine->InitEngine( rulesFile );
99 else
100 m_DRCEngine->InitEngine( wxFileName() );
101
102 aBoard->GetDesignSettings().m_DRCEngine = m_DRCEngine;
103 aBoard->BuildListOfNets();
104 aBoard->BuildConnectivity();
105}
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
std::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.

References GetPcbnewTestDataDir(), SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::Prj(), and ReadBoardFromFileOrStream().

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ LoadSchematic()

void KI_TEST::LoadSchematic ( SETTINGS_MANAGER aSettingsManager,
const wxString &  aRelPath,
std::unique_ptr< SCHEMATIC > &  aSchematic 
)

Definition at line 110 of file schematic_file_util.cpp.

112{
113 if( aSchematic )
114 {
115 PROJECT* prj = &aSchematic->Prj();
116
117 aSchematic->SetProject( nullptr );
118 aSettingsManager.UnloadProject( prj, false );
119 aSchematic->Reset();
120 }
121
122 std::string absPath = getEeschemaTestDataDir() + aRelPath.ToStdString();
123 wxFileName projectFile( absPath + ".kicad_pro" );
124 wxFileName legacyProject( absPath + ".pro" );
125 std::string schematicPath = absPath + ".kicad_sch";
126
127 if( projectFile.Exists() )
128 aSettingsManager.LoadProject( projectFile.GetFullPath() );
129 else if( legacyProject.Exists() )
130 aSettingsManager.LoadProject( legacyProject.GetFullPath() );
131 else
132 aSettingsManager.LoadProject( "" );
133
134 aSettingsManager.Prj().SetElem( PROJECT::ELEM_SCH_SYMBOL_LIBS, nullptr );
135
136 aSchematic = ReadSchematicFromFile( schematicPath, &aSettingsManager.Prj() );
137
138 aSchematic->CurrentSheet().push_back( &aSchematic->Root() );
139
140 SCH_SCREENS screens( aSchematic->Root() );
141
142 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
143 screen->UpdateLocalLibSymbolLinks();
144
145 SCH_SHEET_LIST sheets = aSchematic->GetSheets();
146
147 // Restore all of the loaded symbol instances from the root sheet screen.
148 sheets.UpdateSymbolInstances( aSchematic->RootScreen()->GetSymbolInstances() );
149 sheets.UpdateSheetInstances( aSchematic->RootScreen()->GetSheetInstances() );
150
151 sheets.AnnotatePowerSymbols();
152
153 // NOTE: This is required for multi-unit symbols to be correct
154 // Normally called from SCH_EDIT_FRAME::FixupJunctions() but could be refactored
155 for( SCH_SHEET_PATH& sheet : sheets )
156 sheet.UpdateAllScreenReferences();
157
158 // NOTE: SchematicCleanUp is not called; QA schematics must already be clean or else
159 // SchematicCleanUp must be freed from its UI dependencies.
160
161 aSchematic->ConnectionGraph()->Recalculate( sheets, true );
162}
Container for project specific data.
Definition: project.h:63
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:293
@ ELEM_SCH_SYMBOL_LIBS
Definition: project.h:207
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:613
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void UpdateSheetInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
std::unique_ptr< SCHEMATIC > ReadSchematicFromFile(const std::string &aFilename, PROJECT *aProject)
std::string getEeschemaTestDataDir()

References SCH_SHEET_LIST::AnnotatePowerSymbols(), PROJECT::ELEM_SCH_SYMBOL_LIBS, getEeschemaTestDataDir(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::Prj(), ReadSchematicFromFile(), PROJECT::SetElem(), SETTINGS_MANAGER::UnloadProject(), SCH_SHEET_LIST::UpdateSheetInstances(), and SCH_SHEET_LIST::UpdateSymbolInstances().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::TestNetlist().

◆ ReadBoardFromFileOrStream()

std::unique_ptr< BOARD > KI_TEST::ReadBoardFromFileOrStream ( const std::string &  aFilename,
std::istream &  aFallback = std::cin 
)

Read a board from a file, or another stream, as appropriate.

Parameters
aFilenameThe file to read, or the fallback if empty
aFallbackthe fallback stream
Returns
a BOARD, if successful

Definition at line 93 of file board_file_utils.cpp.

95{
96 std::istream* in_stream = nullptr;
97 std::ifstream file_stream;
98
99 if( aFilename.empty() )
100 {
101 // no file, read stdin
102 in_stream = &aFallback;
103 }
104 else
105 {
106 file_stream.open( aFilename );
107 in_stream = &file_stream;
108 }
109
110 return ReadItemFromStream<BOARD>( *in_stream );
111}

Referenced by BOOST_FIXTURE_TEST_CASE(), LoadBoard(), loadKicadProject(), polygon_gererator_main(), polygon_triangulation_main(), and testSaveLoad().

◆ ReadBoardItemFromStream()

std::unique_ptr< BOARD_ITEM > KI_TEST::ReadBoardItemFromStream ( std::istream &  aStream)

Utility function to read a BOARD_ITEM (probably a FOOTPRINT or a BOARD) from a file.

Helps when writing tests or utilities that can be fed an external file.

Parameters
aFilenamethe file to read in
Returns
a new BOARD_ITEM, which is nullptr if the read or parse failed.

Definition at line 72 of file board_file_utils.cpp.

73{
74 // Take input from stdin
76 reader.SetStream( aStream );
77
78 PCB_PARSER parser( &reader, nullptr, nullptr );
79 std::unique_ptr<BOARD_ITEM> board;
80
81 try
82 {
83 board.reset( parser.Parse() );
84 }
85 catch( const IO_ERROR& )
86 {
87 }
88
89 return board;
90}
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
Definition: pcb_parser.h:74
LINE_READER that wraps a given std::istream instance.
void SetStream(std::istream &aStream)
Set the stream for this line reader.

References PCB_PARSER::Parse(), and STDISTREAM_LINE_READER::SetStream().

Referenced by ReadItemFromStream().

◆ ReadItemFromStream()

template<typename ITEM >
std::unique_ptr< ITEM > KI_TEST::ReadItemFromStream ( std::istream &  aStream)

Read a specific kind of BOARD_ITEM from a stream.

Template Parameters
ITEMthe item type to return (probably a FOOTPRINT or BOARD)
Parameters
aStreamthe stream to read from.

Definition at line 77 of file board_file_utils.h.

78{
79 auto bi_ptr = ReadBoardItemFromStream( aStream );
80 std::unique_ptr<ITEM> downcast_ptr;
81
82 // if it's the right type, downcast and "steal" (and we'll return ownership)
83 ITEM* const tmp = dynamic_cast<ITEM*>( bi_ptr.get() );
84 if( tmp != nullptr )
85 {
86 bi_ptr.release();
87 downcast_ptr.reset( tmp );
88 }
89
90 return downcast_ptr;
91}
std::unique_ptr< BOARD_ITEM > ReadBoardItemFromStream(std::istream &aStream)
Utility function to read a BOARD_ITEM (probably a FOOTPRINT or a BOARD) from a file.

References ReadBoardItemFromStream().

◆ ReadSchematicFromFile()

std::unique_ptr< SCHEMATIC > KI_TEST::ReadSchematicFromFile ( const std::string &  aFilename,
PROJECT aProject 
)

Definition at line 99 of file schematic_file_util.cpp.

100{
101 std::ifstream file_stream;
102 file_stream.open( aFilename );
103
104 wxASSERT( file_stream.is_open() );
105
106 return ReadSchematicFromStream( file_stream, aProject );
107}
std::unique_ptr< SCHEMATIC > ReadSchematicFromStream(std::istream &aStream, PROJECT *aProject)

References ReadSchematicFromStream().

Referenced by LoadSchematic().

◆ ReadSchematicFromStream()

std::unique_ptr< SCHEMATIC > KI_TEST::ReadSchematicFromStream ( std::istream &  aStream,
PROJECT aProject 
)

Definition at line 74 of file schematic_file_util.cpp.

75{
77 reader.SetStream( aStream );
78
79 SCH_SEXPR_PARSER parser( &reader );
80 std::unique_ptr<SCHEMATIC> schematic( new SCHEMATIC( nullptr ) );
81
82 try
83 {
84 schematic->SetProject( aProject );
85 SCH_SHEET* newSheet = new SCH_SHEET( schematic.get() );
86 schematic->SetRoot( newSheet );
87 SCH_SCREEN* rootScreen = new SCH_SCREEN( schematic.get() );
88 schematic->Root().SetScreen( rootScreen );
89 parser.ParseSchematic( newSheet );
90 }
91 catch( const IO_ERROR& )
92 {
93 }
94
95 return schematic;
96}
Holds all the data relating to one schematic.
Definition: schematic.h:60
Object to parser s-expression symbol library and schematic file formats.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55

References SCH_SEXPR_PARSER::ParseSchematic(), and STDISTREAM_LINE_READER::SetStream().

Referenced by ReadSchematicFromFile().

◆ SexprConvertsToString()

bool KI_TEST::SexprConvertsToString ( const SEXPR::SEXPR aSexpr,
const std::string &  aExpStr 
)
inline

Predicate to check an SEXPR object converts to the expected string.

Parameters
aSexprs-expression
aExpStrexpected string
Returns
true if match

Definition at line 209 of file sexpr_test_utils.h.

210{
211 const std::string converted = aSexpr.AsString();
212
213 bool ok = true;
214
215 if( converted != aExpStr )
216 {
217 BOOST_TEST_INFO( "Sexpr string conversion mismatch: got '" << converted << "', expected '"
218 << aExpStr << "'" );
219 ok = false;
220 }
221
222 return ok;
223}
std::string AsString(size_t aLevel=0) const
Definition: sexpr.cpp:151

References SEXPR::SEXPR::AsString(), and BOOST_TEST_INFO.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SexprIsDouble()

bool KI_TEST::SexprIsDouble ( const SEXPR::SEXPR aSexpr)
inline

Test predicate: is the s-expression a double?

Definition at line 163 of file sexpr_test_utils.h.

164{
166}
bool IsSexprOfType(const SEXPR::SEXPR &aSexpr, SEXPR::SEXPR_TYPE aType)

References IsSexprOfType(), and SEXPR::SEXPR_TYPE_ATOM_DOUBLE.

◆ SexprIsDoubleWithValue()

bool KI_TEST::SexprIsDoubleWithValue ( const SEXPR::SEXPR aSexpr,
double  aVal 
)
inline

Test predicate: is the s-expression a double with the given value?

Definition at line 171 of file sexpr_test_utils.h.

172{
174 && IsSexprValueEqual( aSexpr.GetDouble(), aVal );
175}
double GetDouble() const
Definition: sexpr.cpp:105
bool IsSexprValueEqual(const VAL_T &aGot, const VAL_T &aExpected)
Predicate to check two s-expr values (of the same type) are equal.

References SEXPR::SEXPR::GetDouble(), IsSexprOfType(), IsSexprValueEqual(), and SEXPR::SEXPR_TYPE_ATOM_DOUBLE.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SexprIsInteger()

bool KI_TEST::SexprIsInteger ( const SEXPR::SEXPR aSexpr)
inline

Test predicate: is the s-expression an integer?

Definition at line 146 of file sexpr_test_utils.h.

References IsSexprOfType(), and SEXPR::SEXPR_TYPE_ATOM_INTEGER.

◆ SexprIsIntegerWithValue()

bool KI_TEST::SexprIsIntegerWithValue ( const SEXPR::SEXPR aSexpr,
std::int64_t  aVal 
)
inline

Test predicate: is the s-expression an integer with the given value?

Definition at line 154 of file sexpr_test_utils.h.

155{
157 && IsSexprValueEqual( aSexpr.GetLongInteger(), aVal );
158}
int64_t GetLongInteger() const
Definition: sexpr.cpp:95

References SEXPR::SEXPR::GetLongInteger(), IsSexprOfType(), IsSexprValueEqual(), and SEXPR::SEXPR_TYPE_ATOM_INTEGER.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SexprIsList()

bool KI_TEST::SexprIsList ( const SEXPR::SEXPR aSexpr)
inline

Test predicate: is the s-expression a double?

Definition at line 180 of file sexpr_test_utils.h.

181{
183}

References IsSexprOfType(), and SEXPR::SEXPR_TYPE_LIST.

◆ SexprIsListOfLength()

bool KI_TEST::SexprIsListOfLength ( const SEXPR::SEXPR aSexpr,
size_t  aExpectedLength 
)
inline

Test predicate: is the s-expression a list with the given length?

Definition at line 188 of file sexpr_test_utils.h.

189{
191 return false;
192
193 if( aSexpr.GetNumberOfChildren() != aExpectedLength )
194 {
195 BOOST_TEST_MESSAGE( "List is wrong length: got " << aSexpr.GetNumberOfChildren()
196 << ", expected " << aExpectedLength );
197 return false;
198 }
199
200 return true;
201}
size_t GetNumberOfChildren() const
Definition: sexpr.cpp:70

References SEXPR::SEXPR::GetNumberOfChildren(), IsSexprOfType(), and SEXPR::SEXPR_TYPE_LIST.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SexprIsString()

bool KI_TEST::SexprIsString ( const SEXPR::SEXPR aSexpr)
inline

Test predicate: is the s-expression a string?

Definition at line 129 of file sexpr_test_utils.h.

130{
132}

References IsSexprOfType(), and SEXPR::SEXPR_TYPE_ATOM_STRING.

◆ SexprIsStringWithValue()

bool KI_TEST::SexprIsStringWithValue ( const SEXPR::SEXPR aSexpr,
const std::string &  aVal 
)
inline

Test predicate: is the s-expression a string with the given value?

Definition at line 137 of file sexpr_test_utils.h.

138{
140 && IsSexprValueEqual( aSexpr.GetString(), aVal );
141}
std::string const & GetString() const
Definition: sexpr.cpp:80

References SEXPR::SEXPR::GetString(), IsSexprOfType(), IsSexprValueEqual(), and SEXPR::SEXPR_TYPE_ATOM_STRING.

Referenced by BOOST_AUTO_TEST_CASE().

◆ SexprIsSymbol()

bool KI_TEST::SexprIsSymbol ( const SEXPR::SEXPR aSexpr)
inline

Test predicate: is the s-expression a symbol?

Definition at line 112 of file sexpr_test_utils.h.

113{
115}

References IsSexprOfType(), and SEXPR::SEXPR_TYPE_ATOM_SYMBOL.

◆ SexprIsSymbolWithValue()

bool KI_TEST::SexprIsSymbolWithValue ( const SEXPR::SEXPR aSexpr,
const std::string &  aVal 
)
inline

Test predicate: is the s-expression a symbol with the given value?

Definition at line 120 of file sexpr_test_utils.h.

121{
123 && IsSexprValueEqual( aSexpr.GetSymbol(), aVal );
124}
std::string const & GetSymbol() const
Definition: sexpr.cpp:128

References SEXPR::SEXPR::GetSymbol(), IsSexprOfType(), IsSexprValueEqual(), and SEXPR::SEXPR_TYPE_ATOM_SYMBOL.

Referenced by BOOST_AUTO_TEST_CASE().