KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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...
 
class  CONSOLE_LOG
 
class  CONSOLE_MSG_REPORTER
 
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 PCB_TEXT *expected, const PCB_TEXT *text)
 
void CheckFpShape (const PCB_SHAPE *expected, const PCB_SHAPE *shape)
 
void CheckFpZone (const ZONE *expected, const 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...
 
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...
 
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 ()
 Get the configured location of Eeschema test data. More...
 
void DumpSchematicToFile (SCHEMATIC &aSchematic, SCH_SHEET &aSheet, const std::string &aFilename)
 
void LoadSheetSchematicContents (const std::string &fileName, SCH_SHEET *sheet)
 
void LoadHierarchy (SCHEMATIC *schematic, SCH_SHEET *sheet, const std::string &sheetFilename, std::unordered_map< std::string, SCH_SCREEN * > &parsedScreens)
 
std::unique_ptr< SCHEMATICLoadHierarchyFromRoot (const std::string &rootFilename, PROJECT *project)
 
void LoadSchematic (SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
 
std::unique_ptr< SCHEMATICReadSchematicFromStream (std::istream &aStream, PROJECT *aProject)
 
std::unique_ptr< SCHEMATICReadSchematicFromFile (const std::string &aFilename, PROJECT *aProject)
 
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...
 
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...
 
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 227 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 228 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 247 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.

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.

References BOOST_TEST_INFO, and FieldNameIdMatches().

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.

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

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

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

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

References SHAPE_POLY_SET::AddOutline().

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

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.

References BuildRectChain().

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

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

◆ CheckFootprint()

◆ CheckFpPad()

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

Definition at line 259 of file board_test_utils.cpp.

References BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, expected, and pad.

Referenced by CheckFootprint().

◆ CheckFpShape()

◆ CheckFpText()

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

Definition at line 310 of file board_test_utils.cpp.

References BOOST_TEST_CONTEXT, CHECK_ENUM_CLASS_EQUAL, expected, and text.

Referenced by CheckFootprint().

◆ CheckFpZone()

◆ CheckShapePolySet()

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

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

References expected.

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

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 62 of file board_construction_utils.cpp.

References FOOTPRINT::Add(), FOOTPRINT::GetOrientation(), and FOOTPRINT::GetPosition().

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 52 of file board_construction_utils.cpp.

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 81 of file board_construction_utils.cpp.

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.

References SEG::A, FOOTPRINT::Add(), SEG::B, FOOTPRINT::GetOrientation(), and FOOTPRINT::GetPosition().

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.

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 41 of file schematic_file_util.cpp.

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.

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

Referenced by AreDefaultFieldsCorrect(), and BOOST_AUTO_TEST_CASE().

◆ FillZones()

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

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 ( )

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 43 of file unit_test_utils.cpp.

References QA_EESCHEMA_DATA_LOCATION.

Referenced by getCadstarTestFile(), getEagleTestSchematic(), TEST_SIM_LIBRARY_SPICE_FIXTURE::GetLibraryPath(), KI_TEST::SCHEMATIC_TEST_FIXTURE::GetSchematicPath(), TEST_NETLIST_EXPORTER_SPICE_FIXTURE::GetSchematicPath(), TEST_SIM_REGRESSIONS_FIXTURE::GetSchematicPath(), TEST_SCH_SHEET_LIST_FIXTURE::GetSchematicPath(), and LoadSchematic().

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

References QA_PCBNEW_DATA_LOCATION.

Referenced by BOOST_AUTO_TEST_CASE(), createTestCases(), and LoadBoard().

◆ GetSexprDebugType()

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

◆ getType()

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

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

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

Referenced by BOOST_AUTO_TEST_CASE().

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

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, and KIGFX::COLOR4D::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.

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

References BOOST_TEST_INFO, and IsColorNearHex().

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsSexprOfType()

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

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 30 of file uuid_test_utils.cpp.

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 39 of file uuid_test_utils.cpp.

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.

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

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.

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.

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.

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.

◆ LoadBoard()

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

◆ LoadHierarchy()

void KI_TEST::LoadHierarchy ( SCHEMATIC schematic,
SCH_SHEET sheet,
const std::string &  sheetFilename,
std::unordered_map< std::string, SCH_SCREEN * > &  parsedScreens 
)

◆ LoadHierarchyFromRoot()

std::unique_ptr< SCHEMATIC > KI_TEST::LoadHierarchyFromRoot ( const std::string &  rootFilename,
PROJECT project 
)

Definition at line 105 of file schematic_file_util.cpp.

References LoadHierarchy(), and project.

Referenced by LoadSchematic().

◆ LoadSchematic()

◆ LoadSheetSchematicContents()

void KI_TEST::LoadSheetSchematicContents ( const std::string &  fileName,
SCH_SHEET sheet 
)

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

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.

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.

References ReadBoardItemFromStream().

◆ ReadSchematicFromFile()

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

◆ ReadSchematicFromStream()

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

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

Referenced by BOOST_AUTO_TEST_CASE().