36#include <nlohmann/json.hpp>
38#include <wx/filename.h>
52 fn.AppendDir( wxS(
"libraries" ) );
53 fn.SetFullName( wxS(
"Device.kicad_sym" ) );
54 return fn.GetFullPath();
68 BOOST_CHECK(
result.Empty() );
80 wxString victimName = mapB.begin()->first;
81 mapB.erase( mapB.begin() );
86 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
111 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
113 BOOST_CHECK_GT(
result.changes[0].bbox.GetWidth(), 0 );
114 BOOST_CHECK_GT(
result.changes[0].bbox.GetHeight(), 0 );
126 BOOST_CHECK( !geometry.
Empty() );
137 mapB.erase( mapB.begin() );
142 nlohmann::json j =
result.ToJson();
157 BOOST_REQUIRE_EQUAL( a.size(), 1u );
158 BOOST_REQUIRE_EQUAL( b.size(), 1u );
159 BOOST_CHECK( a == b );
168 BOOST_CHECK( !( a == b ) );
180 BOOST_REQUIRE_GE( mapB.size(), 3u );
182 std::vector<wxString> victims;
184 for(
int i = 0; i < 3 && !mapB.empty(); ++i )
186 victims.push_back( mapB.begin()->first );
187 mapB.erase( mapB.begin() );
212 BOOST_REQUIRE_GE( mapB1.size(), 2u );
215 mapB1.erase( mapB1.begin() );
216 mapB2.erase( mapB2.begin() );
235 for(
const std::unique_ptr<LIB_SYMBOL>& owner : ownersB )
237 if( owner && !owner->IsDerived() && !owner->GetPins().empty() )
239 victim = owner.get();
264 bool foundPinChild =
false;
269 foundPinChild =
true;
272 BOOST_CHECK( foundPinChild );
283 for(
const std::unique_ptr<LIB_SYMBOL>& owner : ownersB )
285 if( owner && !owner->IsDerived() && !owner->GetPins().empty() )
287 victim = owner.get();
294 victim->
GetPins().front()->SetName( wxS(
"QA_RENAMED_PIN" ) );
312 bool foundPinDelta =
false;
317 foundPinDelta =
true;
320 BOOST_CHECK( foundPinDelta );
331 for(
const std::unique_ptr<LIB_SYMBOL>& owner : ownersB )
333 if( owner && !owner->IsDerived() )
335 victim = owner.get();
389 for(
const std::unique_ptr<LIB_SYMBOL>& sym : owners )
391 if( sym->GetParentName().IsEmpty() )
395 BOOST_CHECK( sym->IsDerived() );
397 std::shared_ptr<LIB_SYMBOL> parent = sym->GetParent().lock();
404 BOOST_CHECK( checked > 0 );
void SetStart(const VECTOR2I &aStart)
void SetEnd(const VECTOR2I &aEnd)
Diff two .kicad_sym symbol libraries.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
static std::pair< std::vector< std::unique_ptr< LIB_SYMBOL > >, SYMBOL_MAP > LoadLibrary(const wxString &aPath)
Convenience: load a .kicad_sym path into a SYMBOL_MAP using SCH_IO_KICAD_SEXPR::EnumerateSymbolLib.
A color representation with 4 components: red, green, blue, alpha.
Define a library symbol object.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
std::vector< SCH_PIN * > GetPins() const override
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
bool empty(int aType=UNDEFINED_TYPE) const
ITERATOR begin(int aType=UNDEFINED_TYPE)
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void Move(const VECTOR2I &aMoveVector)
Move the item by aMoveVector to a new position.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
DOCUMENT_GEOMETRY ExtractSymbolGeometry(const LIB_SYMBOL &aSymbol, const KIGFX::COLOR4D &aColor, int aUnit, int aBodyStyle)
Extract coarse drawable context from a library symbol for visual symbol diffs.
KIID_PATH LibraryItemKiidPath(const wxString &aName)
Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).
std::optional< BOX2I > BBoxFromGeometry(const DOCUMENT_GEOMETRY &aGeometry)
Compute the tight bounding box of a DOCUMENT_GEOMETRY, inflating each primitive by half its stroke so...
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
The full set of changes between two parsed documents of one type.
nlohmann::json ToJson() const
static DOCUMENT_DIFF FromJson(const nlohmann::json &aJson)
std::vector< ITEM_CHANGE > changes
Aggregate of background geometry extracted from one source document.
One change record on a single item.
std::vector< PROPERTY_DELTA > properties
std::optional< wxString > refdes
std::vector< ITEM_CHANGE > children
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_INFO("Two-port Series .op current = "<< iDevice)
static wxString getFixturePath()
BOOST_AUTO_TEST_CASE(IdenticalLibrariesDiffEmpty)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I