37#include <nlohmann/json.hpp>
76 PCB_DIFFER differ( m_before.get(), m_after.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
81 "got " <<
result.changes.size()
82 <<
" change records" );
107 PCB_DIFFER differ( m_before.get(), m_after.get() );
110 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
127 subject =
static_cast<PCB_TRACK*
>( item );
134 int originalWidth = subject->
GetWidth();
135 int newWidth = originalWidth + 50000;
138 PCB_DIFFER differ( m_before.get(), m_after.get() );
141 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
145 bool foundWidthDelta =
false;
149 if( d.
name.Lower().Contains( wxS(
"width" ) ) )
151 foundWidthDelta =
true;
157 BOOST_CHECK_MESSAGE( foundWidthDelta,
"Expected Width property delta after SetWidth() on a track" );
164 std::map<wxString, PCB_TRACK*> tracksByNet;
165 wxString selectedNet;
181 if( tracksByNet.contains( netName ) )
183 selectedNet = netName;
184 first = tracksByNet[netName];
189 tracksByNet[netName] = track;
198 PCB_DIFFER differ( m_before.get(), m_after.get() );
201 std::size_t selectedNetChanges = 0;
205 if( change.
refdes == selectedNet )
207 ++selectedNetChanges;
208 BOOST_CHECK( change.
typeName == wxS(
"PCB_TRACK" ) || change.
typeName == wxS(
"PCB_VIA" ) );
227 if( !fp->
Pads().empty() )
238 pad->SetNumber(
pad->GetNumber() + wxS(
"X" ) );
240 PCB_DIFFER differ( m_before.get(), m_after.get() );
244 BOOST_REQUIRE_EQUAL(
result.changes.size(), 1u );
247 BOOST_REQUIRE_EQUAL(
result.changes[0].children.size(), 1u );
250 pad->m_Uuid.AsString().ToStdString() );
263 subject =
static_cast<PCB_TRACK*
>( item );
271 PCB_DIFFER differ1( m_before.get(), m_after.get() );
272 PCB_DIFFER differ2( m_before.get(), m_after.get() );
290 subject =
static_cast<PCB_TRACK*
>( item );
298 PCB_DIFFER differ( m_before.get(), m_after.get(), wxS(
"complex_hierarchy.kicad_pcb" ) );
301 nlohmann::json j =
result.ToJson();
306 BOOST_REQUIRE_EQUAL( back.
changes.size(),
result.changes.size() );
307 BOOST_CHECK( back.
changes[0].kind ==
result.changes[0].kind );
317 BOOST_CHECK( !geometry.
Empty() );
319 LSET expectedTrackLayers;
321 for(
const PCB_TRACK* track : m_after->Tracks() )
324 expectedTrackLayers |= track->GetLayerSet();
330 BOOST_CHECK( ( geometryLayers & expectedTrackLayers ).
any() );
332 bool segmentWithLayer =
false;
336 if( segment.
layers.any() )
338 segmentWithLayer =
true;
343 BOOST_CHECK( segmentWithLayer );
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
wxString GetNetname() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Diff two already-parsed BOARDs and produce a DOCUMENT_DIFF.
DOCUMENT_DIFF Diff() override
Produce a DOCUMENT_DIFF of the inputs the concrete differ was constructed with.
A color representation with 4 components: red, green, blue, alpha.
wxString AsString() const
LSET is a set of PCB_LAYER_IDs.
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
A type-safe container of any type.
LSET GeometryLayerSet(const DOCUMENT_GEOMETRY &aGeometry)
Return the union of every non-empty layer set carried by the geometry.
DOCUMENT_GEOMETRY ExtractBoardGeometry(const BOARD &aBoard, const KIGFX::COLOR4D &aColor)
Extract a coarse outline of a BOARD into a DOCUMENT_GEOMETRY for use as background context in DIFF_SC...
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
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.
std::vector< DOCUMENT_SEGMENT > segments
Stroked line segment from one of the source documents.
One change record on a single item.
std::optional< wxString > refdes
Single (name, before, after) triple for one mutated property on an item.
Fixture: loads the same canonical board into two separate BOARD instances so tests can mutate one and...
std::unique_ptr< BOARD > m_before
SETTINGS_MANAGER m_settingsA
SETTINGS_MANAGER m_settingsB
std::unique_ptr< BOARD > m_after
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TwoFreshLoadsAreIdentical)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)