KiCad PCB EDA Suite
|
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 |
class | DUMMY_TOOL |
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. | |
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. | |
void | DrawPolyline (FOOTPRINT &aFootprint, const std::vector< VECTOR2I > &aPts, int aWidth, PCB_LAYER_ID aLayer) |
Draw a polyline - a set of linked segments. | |
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. | |
void | DrawRect (FOOTPRINT &aFootprint, const VECTOR2I &aPos, const VECTOR2I &aSize, int aRadius, int aWidth, PCB_LAYER_ID aLayer) |
Draw a rectangle on a footprint. | |
std::string | GetPcbnewTestDataDir () |
Utility which returns a path to the data directory where the test board files are stored. | |
void | DumpBoardToFile (BOARD &aBoard, const std::string &aFilename) |
Utility function to simply write a Board out to a file. | |
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. | |
std::unique_ptr< BOARD > | ReadBoardFromFileOrStream (const std::string &aFilename, std::istream &aFallback=std::cin) |
Read a board from a file, or another stream, as appropriate. | |
std::unique_ptr< FOOTPRINT > | ReadFootprintFromFileOrStream (const std::string &aFilename, std::istream &aFallback) |
void | LoadBoard (SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard) |
BOARD_ITEM & | RequireBoardItemWithTypeAndId (const BOARD &aBoard, KICAD_T aItemType, const KIID &aID) |
Get an item from the given board with a certain type and UUID. | |
void | LoadAndTestBoardFile (const wxString aRelativePath, bool aRoundtrip, std::function< void(BOARD &)> aBoardTestFunction, std::optional< int > aExpectedBoardVersion=std::nullopt) |
Perform "some test" on a board file loaded from the path, then optionally save and reload and run the test again. | |
void | FillZones (BOARD *m_board) |
void | CheckFootprint (const FOOTPRINT *expected, const FOOTPRINT *fp) |
Helper method to check if two footprints are semantically the same. | |
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. | |
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. | |
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. | |
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) | |
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. | |
SEG | BuildHSeg (const VECTOR2I &aStart, int aLength) |
Build a horizontal segment from a point with a length. | |
SEG | BuildVSeg (const VECTOR2I &aStart, int aLength) |
Build a vertical segment from a point with a length. | |
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. | |
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. | |
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. | |
template<typename T > | |
bool | IsWithin (T aValue, T aNominal, T aError) |
Check if a value is within a tolerance of a nominal value. | |
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. | |
template<typename T > | |
bool | IsWithinAndBelow (T aValue, T aNominal, T aErrorBelow) |
value is in range [aNominal - aErrorBelow, aNominal] | |
template<typename T > | |
bool | IsWithinAndAbove (T aValue, T aNominal, T aErrorAbove) |
value is in range [aNominal, aNominal + aErrorAbove] | |
bool | IsUUID (const std::string &aStr) |
Check if the string between the iterators looks like a UUID. | |
bool | IsUUIDPathWithLevels (const std::string &aStr, unsigned aLevels) |
Predicate to check a string is a UUID path format. | |
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. | |
template<typename T > | |
bool | CollectionHasNoDuplicates (const T &aCollection) |
Predicate to check a collection has no duplicate elements. | |
std::string | GetEeschemaTestDataDir () |
Get the configured location of Eeschema test data. | |
void | wxAssertThrower (const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg) |
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< SCHEMATIC > | LoadHierarchyFromRoot (const std::string &rootFilename, PROJECT *project) |
void | LoadSchematic (SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic) |
std::unique_ptr< SCHEMATIC > | ReadSchematicFromStream (std::istream &aStream, PROJECT *aProject) |
std::unique_ptr< SCHEMATIC > | ReadSchematicFromFile (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. | |
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. | |
bool | IsImagePixelOfColor (const wxImage &aImage, int aX, int aY, const KIGFX::COLOR4D &aColor) |
Predicate to check an image pixel matches color and alpha. | |
bool | FieldNameIdMatches (const SCH_FIELD &aField, const std::string &aExpectedName, int aExpectedId) |
Predicate to check a field name is as expected. | |
bool | AreDefaultFieldsCorrect (const std::vector< SCH_FIELD > &aFields) |
Predicate to check that the mandatory fields look sensible. | |
SEXPR::SEXPR_TYPE | getType (const SEXPR::SEXPR &aSexpr) |
Get the type of the s-expression. | |
std::string | getDebugType (SEXPR::SEXPR_TYPE aType) |
Get a debug-friendly string for a given s-expr type. | |
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. | |
bool | SexprIsSymbol (const SEXPR::SEXPR &aSexpr) |
Test predicate: is the s-expression a symbol? | |
bool | SexprIsSymbolWithValue (const SEXPR::SEXPR &aSexpr, const std::string &aVal) |
Test predicate: is the s-expression a symbol with the given value? | |
bool | SexprIsString (const SEXPR::SEXPR &aSexpr) |
Test predicate: is the s-expression a string? | |
bool | SexprIsStringWithValue (const SEXPR::SEXPR &aSexpr, const std::string &aVal) |
Test predicate: is the s-expression a string with the given value? | |
bool | SexprIsInteger (const SEXPR::SEXPR &aSexpr) |
Test predicate: is the s-expression an integer? | |
bool | SexprIsIntegerWithValue (const SEXPR::SEXPR &aSexpr, std::int64_t aVal) |
Test predicate: is the s-expression an integer with the given value? | |
bool | SexprIsDouble (const SEXPR::SEXPR &aSexpr) |
Test predicate: is the s-expression a double? | |
bool | SexprIsDoubleWithValue (const SEXPR::SEXPR &aSexpr, double aVal) |
Test predicate: is the s-expression a double with the given value? | |
bool | SexprIsList (const SEXPR::SEXPR &aSexpr) |
Test predicate: is the s-expression a double? | |
bool | SexprIsListOfLength (const SEXPR::SEXPR &aSexpr, size_t aExpectedLength) |
Test predicate: is the s-expression a list with the given length? | |
bool | SexprConvertsToString (const SEXPR::SEXPR &aSexpr, const std::string &aExpStr) |
Predicate to check an SEXPR object converts to the expected string. | |
bool | IsDrcMarkerOfType (const PCB_MARKER &aMarker, int aErrorCode) |
Predicate for testing the type of a DRC marker. | |
using KI_TEST::EXP_OBJ = typedef typename EXP_CONT::value_type |
Definition at line 149 of file unit_test_utils.h.
using KI_TEST::FOUND_OBJ = typedef typename FOUND_CONT::value_type |
Definition at line 150 of file unit_test_utils.h.
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.
EXP_OBJ | the "expected" object type |
FOUND_OBJ | the "found" object type |
Definition at line 169 of file unit_test_utils.h.
enum KI_TEST::RET_CODES |
Return codes for tools.
Definition at line 38 of file utility_program.h.
bool KI_TEST::AreDefaultFieldsCorrect | ( | const std::vector< SCH_FIELD > & | aFields | ) |
Predicate to check that the mandatory fields look sensible.
Definition at line 86 of file lib_field_test_utils.h.
References FieldNameIdMatches().
Referenced by BOOST_AUTO_TEST_CASE().
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.
aOuterSize | the size (x and y) of the outer square |
aInnerSize | the size (x and y) of the hole |
aCentre | the centre point of both squares (default: origin) |
Definition at line 44 of file poly_set_construction.cpp.
References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), and BuildRectChain().
Build a horizontal segment from a point with a length.
aStart | the starting point |
aLength | the segment length |
Definition at line 29 of file seg_construction.cpp.
References VECTOR2< T >::x, and VECTOR2< T >::y.
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().
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.
aSize | the rectangle size |
aCentre | centre 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().
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.
aSize | the square size (x == y) |
aCentre | centre of the square |
Definition at line 44 of file line_chain_construction.cpp.
References BuildRectChain().
Referenced by TestSquareFillet().
Build a vertical segment from a point with a length.
aStart | the starting point |
aLength | the segment length |
Definition at line 34 of file seg_construction.cpp.
References VECTOR2< T >::x, and VECTOR2< T >::y.
Helper method to check if two footprints are semantically the same.
Definition at line 231 of file board_test_utils.cpp.
References CHECK_ENUM_CLASS_EQUAL, CheckFpPad(), CheckFpShape(), CheckFpText(), CheckFpZone(), BOARD_ITEM::DRC, expected, FOOTPRINT::Fields(), FOOTPRINT::GetAttributes(), FOOTPRINT::GetFlag(), FOOTPRINT::GetKeywords(), FOOTPRINT::GetLibDescription(), FOOTPRINT::GetOrientation(), FOOTPRINT::GetPosition(), FOOTPRINT::GetReference(), FOOTPRINT::GetTypeName(), FOOTPRINT::GetValue(), FOOTPRINT::GraphicalItems(), FOOTPRINT::Groups(), FOOTPRINT::Models(), FOOTPRINT::Pads(), PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_SHAPE_T, PCB_TEXT_T, text, EDA_ITEM::Type(), and FOOTPRINT::Zones().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_DATA_TEST_CASE().
Definition at line 329 of file board_test_utils.cpp.
References PADSTACK::ALL_LAYERS, CHECK_ENUM_CLASS_EQUAL, CheckFpShape(), expected, and pad.
Referenced by CheckFootprint().
Definition at line 437 of file board_test_utils.cpp.
References CHECK_ENUM_CLASS_EQUAL, CheckShapePolySet(), expected, EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetFillMode(), PCB_SHAPE::GetLayerSet(), STROKE_PARAMS::GetLineStyle(), EDA_SHAPE::GetPolyShape(), PCB_SHAPE::GetPosition(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), PCB_SHAPE::GetStroke(), STROKE_PARAMS::GetWidth(), BOARD_ITEM::IsLocked(), and EDA_ITEM::Type().
Referenced by CheckFootprint(), and CheckFpPad().
Definition at line 405 of file board_test_utils.cpp.
References CHECK_ENUM_CLASS_EQUAL, expected, and text.
Referenced by CheckFootprint().
Definition at line 476 of file board_test_utils.cpp.
References CHECK_ENUM_CLASS_EQUAL, CheckShapePolySet(), expected, 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(), ZONE::Outline(), and EDA_ITEM::Type().
Referenced by CheckFootprint().
void KI_TEST::CheckShapePolySet | ( | const SHAPE_POLY_SET * | expected, |
const SHAPE_POLY_SET * | polyset | ||
) |
Definition at line 527 of file board_test_utils.cpp.
References SHAPE_LINE_CHAIN::ArcCount(), expected, SHAPE_LINE_CHAIN::GetPoint(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), and SHAPE_POLY_SET::TotalVertices().
Referenced by CheckFpShape(), and CheckFpZone().
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:
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:
operator<<
(for logging)Not needed:
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
aExpected | a container of "expected" items, usually from a test case |
aMatched | a container of "found" items, usually the result of some routine under test |
aMatchPredicate | a predicate that determines if a given "found" object matches a given "expected" object. |
Definition at line 206 of file unit_test_utils.h.
References expected.
Referenced by BOOST_AUTO_TEST_CASE(), CheckCollisionsMatchExpected(), and CheckInvalidsMatchExpected().
bool KI_TEST::CollectionHasNoDuplicates | ( | const T & | aCollection | ) |
Predicate to check a collection has no duplicate elements.
Definition at line 252 of file unit_test_utils.h.
Referenced by BOOST_AUTO_TEST_CASE().
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.
aMod | The footprint to add the segment to |
aCentre | The arc centre |
aStart | The arc start point |
aAngle | The arc angle |
aWidth | The width of the arc segment |
aLayer | The 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().
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.
aMod | The footprint to add the segment to |
aPts | The polyline points |
aWidth | The width of the segments |
aLayer | The layer to draw on |
Definition at line 52 of file board_construction_utils.cpp.
References DrawSegment().
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.
aMod | The footprint to add the rectangle to |
aPos | Rectangle centre point |
aSize | Rectangle size (x, y) |
aRadius | Corner radius (0 for a normal rect) |
aWidth | Line width |
aLayer | Layer 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().
void KI_TEST::DrawSegment | ( | FOOTPRINT & | aFootprint, |
const SEG & | aSeg, | ||
int | aWidth, | ||
PCB_LAYER_ID | aLayer | ||
) |
Draw a segment in the given footprint.
aMod | The footprint to add the segment to |
aSeg | The segment geometry |
aWidth | The width of the segment |
aLayer | The 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().
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_IO_KICAD_SEXPR API.
Note: The aBoard param is non-const because PCB_IO_KICAD_SEXPR::Save demands it and I am not confident a const_cast will be a true assurance.
aBoard | the board to write out |
aFilename | the filename to write to |
Definition at line 66 of file board_file_utils.cpp.
References PCB_IO_KICAD_SEXPR::SaveBoard().
Referenced by BOOST_FIXTURE_TEST_CASE(), KI_TEST::BOARD_DUMPER::DumpBoardToFile(), LoadAndTestBoardFile(), and testSaveLoad().
void KI_TEST::DumpSchematicToFile | ( | SCHEMATIC & | aSchematic, |
SCH_SHEET & | aSheet, | ||
const std::string & | aFilename | ||
) |
Definition at line 40 of file schematic_file_util.cpp.
References SCH_IO_KICAD_SEXPR::SaveSchematicFile().
bool KI_TEST::FieldNameIdMatches | ( | const SCH_FIELD & | aField, |
const std::string & | aExpectedName, | ||
int | aExpectedId | ||
) |
Predicate to check a field name is as expected.
aField | SCH_FIELD to check the name |
aExpectedName | the expected field name |
aExpectedId | the expected field id |
Definition at line 61 of file lib_field_test_utils.h.
References SCH_FIELD::GetCanonicalName(), and SCH_FIELD::GetId().
Referenced by AreDefaultFieldsCorrect(), and BOOST_AUTO_TEST_CASE().
void KI_TEST::FillZones | ( | BOARD * | m_board | ) |
Definition at line 170 of file board_test_utils.cpp.
References _, BOARD::BuildConnectivity(), ZONE_FILLER::Fill(), BOARD_COMMIT::Push(), TOOL_MANAGER::RegisterTool(), TOOL_MANAGER::SetEnvironment(), SKIP_CONNECTIVITY, SKIP_SET_DIRTY, SKIP_UNDO, ZONE_FILL_OP, and BOARD::Zones().
Referenced by BOOST_FIXTURE_TEST_CASE().
|
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().
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.
Definition at line 37 of file unit_test_utils.cpp.
References QA_EESCHEMA_DATA_LOCATION.
Referenced by BOOST_AUTO_TEST_CASE(), 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(), TEST_SCHEMATIC_FIXTURE::GetSchematicPath(), and LoadSchematic().
std::string KI_TEST::GetPcbnewTestDataDir | ( | ) |
Utility which returns a path to the data directory where the test board files are stored.
Definition at line 43 of file board_file_utils.cpp.
References QA_PCBNEW_DATA_LOCATION.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_DATA_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), createTestCases(), LoadAndTestBoardFile(), and LoadBoard().
|
inline |
Definition at line 76 of file sexpr_test_utils.h.
References getDebugType(), and getType().
Referenced by SEXPR::boost_test_print_type().
|
inline |
Get the type of the s-expression.
Definition at line 38 of file sexpr_test_utils.h.
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().
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 61 of file geometry.h.
|
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().
|
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().
bool KI_TEST::IsDrcMarkerOfType | ( | const PCB_MARKER & | aMarker, |
int | aErrorCode | ||
) |
Predicate for testing the type of a DRC marker.
aMarker | the marker to test |
aErrorCode | the expected DRC violation code |
Definition at line 41 of file drc_test_utils.cpp.
References MARKER_BASE::GetRCItem().
Referenced by CheckCollisionsMatchExpected().
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.
aImage | the image to check |
aX | pixel x-coordinate |
aY | pixel y-coordinate |
aColor | expected color (alpha is 1.0 if image doesn't support alpha) |
aImage | the image to check |
aX | pixel x-coordinate |
aY | pixel y-coordinate |
aColor | expected color (alpha is 1.0 if image doesn't support alpha) |
Definition at line 40 of file wximage_test_utils.cpp.
References IsColorNearHex().
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 81 of file sexpr_test_utils.h.
References getDebugType(), and getType().
Referenced by SexprIsDouble(), SexprIsDoubleWithValue(), SexprIsInteger(), SexprIsIntegerWithValue(), SexprIsList(), SexprIsListOfLength(), SexprIsString(), SexprIsStringWithValue(), SexprIsSymbol(), and SexprIsSymbolWithValue().
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.
Definition at line 98 of file sexpr_test_utils.h.
Referenced by SexprIsDoubleWithValue(), SexprIsIntegerWithValue(), SexprIsStringWithValue(), and SexprIsSymbolWithValue().
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().
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/
aStr | candidate string |
levels | expected levels |
Definition at line 39 of file uuid_test_utils.cpp.
References IsUUID().
Referenced by BOOST_AUTO_TEST_CASE().
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 51 of file geometry.h.
bool KI_TEST::IsWithin | ( | T | aValue, |
T | aNominal, | ||
T | aError | ||
) |
Check if a value is within a tolerance of a nominal value.
Definition at line 57 of file numeric.h.
Referenced by GEOM_TEST::ArePerpendicular(), and GEOM_TEST::IsPointAtDistance().
bool KI_TEST::IsWithinAndAbove | ( | T | aValue, |
T | aNominal, | ||
T | aErrorAbove | ||
) |
value is in range [aNominal, aNominal + aErrorAbove]
Definition at line 84 of file numeric.h.
References IsWithinBounds().
bool KI_TEST::IsWithinAndBelow | ( | T | aValue, |
T | aNominal, | ||
T | aErrorBelow | ||
) |
value is in range [aNominal - aErrorBelow, aNominal]
Definition at line 76 of file numeric.h.
References IsWithinBounds().
bool KI_TEST::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.
Definition at line 68 of file numeric.h.
Referenced by IsWithinAndAbove(), and IsWithinAndBelow().
bool KI_TEST::IsWithinWrapped | ( | T | aValue, |
T | aNominal, | ||
T | aWrap, | ||
T | aError | ||
) |
void KI_TEST::LoadAndTestBoardFile | ( | const wxString | aRelativePath, |
bool | aRoundtrip, | ||
std::function< void(BOARD &)> | aBoardTestFunction, | ||
std::optional< int > | aExpectedBoardVersion = std::nullopt |
||
) |
Perform "some test" on a board file loaded from the path, then optionally save and reload and run the test again.
The roundtrip is useful to test stability of serialisation/reload.
aRelativePath | relative path of file to load |
aRoundtrip | true to save, reload and re-test |
aBoardTestFunction | the function that runs tests on the board |
aExpectedBoardVersion | the expected board version, or nullopt to not check |
Definition at line 130 of file board_test_utils.cpp.
References DumpBoardToFile(), GetPcbnewTestDataDir(), and ReadBoardFromFileOrStream().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().
void KI_TEST::LoadBoard | ( | SETTINGS_MANAGER & | aSettingsManager, |
const wxString & | aRelPath, | ||
std::unique_ptr< BOARD > & | aBoard | ||
) |
Definition at line 71 of file board_test_utils.cpp.
References GetPcbnewTestDataDir(), SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::Prj(), ReadBoardFromFileOrStream(), and IO_ERROR::What().
Referenced by BOOST_FIXTURE_TEST_CASE().
void KI_TEST::LoadHierarchy | ( | SCHEMATIC * | schematic, |
SCH_SHEET * | sheet, | ||
const std::string & | sheetFilename, | ||
std::unordered_map< std::string, SCH_SCREEN * > & | parsedScreens | ||
) |
Definition at line 57 of file schematic_file_util.cpp.
References SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), LoadHierarchy(), LoadSheetSchematicContents(), EE_RTREE::OfType(), SCH_SHEET_T, SCH_SCREEN::SetFileName(), EDA_ITEM::SetParent(), and SCH_SHEET::SetScreen().
Referenced by LoadHierarchy(), and LoadHierarchyFromRoot().
std::unique_ptr< SCHEMATIC > KI_TEST::LoadHierarchyFromRoot | ( | const std::string & | rootFilename, |
PROJECT * | project | ||
) |
Definition at line 104 of file schematic_file_util.cpp.
References LoadHierarchy(), and project.
Referenced by LoadSchematic().
void KI_TEST::LoadSchematic | ( | SETTINGS_MANAGER & | aSettingsManager, |
const wxString & | aRelPath, | ||
std::unique_ptr< SCHEMATIC > & | aSchematic | ||
) |
Definition at line 119 of file schematic_file_util.cpp.
References SCH_SHEET_LIST::AnnotatePowerSymbols(), SCH_SCREENS::FixLegacyPowerSymbolMismatches(), GetEeschemaTestDataDir(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), LoadHierarchyFromRoot(), SETTINGS_MANAGER::LoadProject(), SETTINGS_MANAGER::Prj(), PROJECT::SCH_SYMBOL_LIBS, PROJECT::SetElem(), SETTINGS_MANAGER::UnloadProject(), SCH_SHEET_LIST::UpdateSheetInstanceData(), and SCH_SHEET_LIST::UpdateSymbolInstanceData().
Referenced by BOOST_FIXTURE_TEST_CASE(), and TEST_NETLIST_EXPORTER_FIXTURE< Exporter >::TestNetlist().
void KI_TEST::LoadSheetSchematicContents | ( | const std::string & | fileName, |
SCH_SHEET * | sheet | ||
) |
Definition at line 46 of file schematic_file_util.cpp.
References SCH_IO_KICAD_SEXPR_PARSER::ParseSchematic(), and STDISTREAM_LINE_READER::SetStream().
Referenced by LoadHierarchy().
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.
aFilename | The file to read, or the fallback if empty |
aFallback | the fallback stream |
Definition at line 95 of file board_file_utils.cpp.
Referenced by BOOST_FIXTURE_TEST_CASE(), LoadAndTestBoardFile(), LoadBoard(), loadKicadProject(), polygon_gererator_main(), polygon_triangulation_main(), and testSaveLoad().
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.
aFilename | the file to read in |
Definition at line 73 of file board_file_utils.cpp.
References PCB_IO_KICAD_SEXPR_PARSER::Parse(), and STDISTREAM_LINE_READER::SetStream().
Referenced by ReadItemFromStream().
std::unique_ptr< FOOTPRINT > KI_TEST::ReadFootprintFromFileOrStream | ( | const std::string & | aFilename, |
std::istream & | aFallback | ||
) |
Definition at line 122 of file board_file_utils.cpp.
std::unique_ptr< ITEM > KI_TEST::ReadItemFromStream | ( | std::istream & | aStream | ) |
Read a specific kind of BOARD_ITEM from a stream.
aStream | the stream to read from. |
Definition at line 78 of file board_file_utils.h.
References ITEM, and ReadBoardItemFromStream().
std::unique_ptr< SCHEMATIC > KI_TEST::ReadSchematicFromFile | ( | const std::string & | aFilename, |
PROJECT * | aProject | ||
) |
std::unique_ptr< SCHEMATIC > KI_TEST::ReadSchematicFromStream | ( | std::istream & | aStream, |
PROJECT * | aProject | ||
) |
BOARD_ITEM & KI_TEST::RequireBoardItemWithTypeAndId | ( | const BOARD & | aBoard, |
KICAD_T | aItemType, | ||
const KIID & | aID | ||
) |
Get an item from the given board with a certain type and UUID.
If this doesn't exist, it's a BOOST_REQUIRE failure.
aBoard | the board to look in |
aItemType | the required item type |
aID | the required |
Definition at line 119 of file board_test_utils.cpp.
References BOARD::GetItem(), and EDA_ITEM::Type().
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().
|
inline |
Predicate to check an SEXPR object converts to the expected string.
aSexpr | s-expression |
aExpStr | expected string |
Definition at line 209 of file sexpr_test_utils.h.
References SEXPR::SEXPR::AsString().
Referenced by BOOST_AUTO_TEST_CASE().
|
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.
|
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().
|
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.
|
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().
|
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.
|
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().
|
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.
|
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().
|
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.
|
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().
|
inline |
Definition at line 71 of file wx_assert.h.
Referenced by init_unit_test().