24#include <boost/test/unit_test.hpp>
38 int aX = 0,
int aY = 0,
39 std::vector<std::pair<wxString, std::string>> aProps = {} )
42 d.
id.push_back( aUuid );
61 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1 ),
62 make( wxS(
"PCB_VIA" ), id2 ) };
64 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ), id1 ),
65 make( wxS(
"PCB_VIA" ), id2 ) };
82 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1 ),
83 make( wxS(
"PCB_VIA" ), id2 ) };
85 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ), id1 ),
86 make( wxS(
"ZONE" ), id3 ) };
106 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ),
id ),
107 make( wxS(
"PCB_TRACK" ),
id ) };
108 std::vector<ITEM_DESCRIPTOR> b;
124 std::vector<std::pair<wxString, std::string>> props =
125 { { wxS(
"lib_id" ),
"Device:R" }, { wxS(
"reference" ),
"R1" } };
127 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"FOOTPRINT" ), idOld, 100, 200, props ) };
128 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"FOOTPRINT" ), idNew, 100, 200, props ) };
145 std::vector<std::pair<wxString, std::string>> p1 = { { wxS(
"k" ),
"v" } };
146 std::vector<std::pair<wxString, std::string>> p2 = p1;
148 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1, 0, 0, p1 ) };
149 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_VIA" ), id2, 0, 0, p2 ) };
166 auto p = std::vector<std::pair<wxString, std::string>>{ { wxS(
"k" ),
"v" } };
173 BOOST_CHECK_CLOSE( score, 1.0, 0.001 );
180 BOOST_CHECK_CLOSE( score, 0.4, 0.001 );
187 KIID idA1, idA2, idB1, idB2;
189 auto p1 = std::vector<std::pair<wxString, std::string>>{ { wxS(
"k" ),
"X" } };
190 auto p2 = std::vector<std::pair<wxString, std::string>>{ { wxS(
"k" ),
"Y" } };
192 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"FOOTPRINT" ), idA1, 0, 0, p1 ),
193 make( wxS(
"FOOTPRINT" ), idA2, 100, 100, p2 ) };
196 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"FOOTPRINT" ), idB1, 100, 100, p2 ),
197 make( wxS(
"FOOTPRINT" ), idB2, 0, 0, p1 ) };
212 KIID id1, id2, id3, id4;
214 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1 ),
215 make( wxS(
"PCB_TRACK" ), id2 ),
216 make( wxS(
"PCB_TRACK" ), id3 ) };
217 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ), id1 ),
218 make( wxS(
"PCB_TRACK" ), id4 ) };
224 BOOST_CHECK( one.aToB == two.
aToB );
225 BOOST_CHECK( one.aOnly == two.
aOnly );
226 BOOST_CHECK( one.bOnly == two.
bOnly );
246 BOOST_CHECK_CLOSE( score, 0.6, 0.001 );
259 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ),
id ),
260 make( wxS(
"PCB_TRACK" ),
id ) };
261 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ),
id ) };
279 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ),
id ) };
280 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ),
id ),
281 make( wxS(
"PCB_TRACK" ),
id ) };
301 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ),
id ),
302 make( wxS(
"PCB_TRACK" ),
id ) };
303 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"PCB_TRACK" ),
id ) };
310 BOOST_CHECK(
result.duplicatesA.empty() );
313 BOOST_CHECK(
result.bOnly.empty() );
324 auto props = std::vector<std::pair<wxString, std::string>>{ { wxS(
"k" ),
"v" } };
325 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"FOOTPRINT" ), idA, 0, 0, props ) };
326 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"FOOTPRINT" ), idB, 0, 0, props ) };
348 std::vector<ITEM_DESCRIPTOR> aVec = { make( wxS(
"FOOTPRINT" ), idA, 100, 200 ) };
349 std::vector<ITEM_DESCRIPTOR> bVec = { make( wxS(
"FOOTPRINT" ), idB, 100, 200 ) };
370 BOOST_CHECK(
result.aToB.empty() );
371 BOOST_CHECK(
result.bToA.empty() );
372 BOOST_CHECK(
result.aOnly.empty() );
373 BOOST_CHECK(
result.bOnly.empty() );
374 BOOST_CHECK(
result.duplicatesA.empty() );
375 BOOST_CHECK(
result.duplicatesB.empty() );
385 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1 ),
386 make( wxS(
"PCB_TRACK" ), id2 ) };
392 BOOST_CHECK(
result.bOnly.empty() );
403 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"PCB_TRACK" ), id1 ),
404 make( wxS(
"PCB_VIA" ), id2 ) };
405 std::vector<ITEM_DESCRIPTOR> b = a;
410 BOOST_REQUIRE_EQUAL(
result.aToB.size(), 2u );
411 for(
const auto& [aId, bId] :
result.aToB )
414 BOOST_CHECK(
result.bToA.at( bId ) == aId );
427 KIID idA1, idA2, idB1, idB2;
429 auto props = std::vector<std::pair<wxString, std::string>>{
430 { wxS(
"lib_id" ),
"Device:R" },
431 { wxS(
"reference" ),
"R1" } };
433 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"FOOTPRINT" ), idA1, 0, 0, props ),
434 make( wxS(
"FOOTPRINT" ), idA2, 100, 100, props ) };
435 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"FOOTPRINT" ), idB1, 0, 0, props ),
436 make( wxS(
"FOOTPRINT" ), idB2, 100, 100, props ) };
441 BOOST_REQUIRE_EQUAL(
result.aToB.size(), 2u );
442 BOOST_REQUIRE_EQUAL(
result.similarityMatches, 2u );
443 for(
const auto& [aId, bId] :
result.aToB )
446 BOOST_CHECK(
result.bToA.at( bId ) == aId );
456 constexpr int N = 100;
459 std::vector<KIID> aIds(
N );
460 std::vector<KIID> bIds(
N );
462 auto props = std::vector<std::pair<wxString, std::string>>{
463 { wxS(
"lib_id" ),
"Device:R" },
464 { wxS(
"reference" ),
"R1" } };
466 std::vector<ITEM_DESCRIPTOR> a;
467 std::vector<ITEM_DESCRIPTOR> b;
474 for(
int i = 0; i <
N; ++i )
476 a.push_back( make( wxS(
"FOOTPRINT" ), aIds[i], 0, 0, props ) );
477 b.push_back( make( wxS(
"FOOTPRINT" ), bIds[i], 0, 0, props ) );
484 BOOST_REQUIRE_EQUAL( first.
aToB.size(), second.
aToB.size() );
486 for(
const auto& [aId, bId] : first.
aToB )
489 BOOST_CHECK( second.
aToB.at( aId ) == bId );
500 constexpr int N = 1000;
503 std::vector<ITEM_DESCRIPTOR> a;
504 std::vector<ITEM_DESCRIPTOR> b;
508 for(
int i = 0; i <
N; ++i )
517 auto props = std::vector<std::pair<wxString, std::string>>{
518 { wxS(
"lib_id" ), wxString::Format(
"Device:R%d", i ).ToStdString() },
519 { wxS(
"reference" ), wxString::Format(
"R%d", i ).ToStdString() } };
521 a.push_back( make( wxS(
"FOOTPRINT" ), idA, i, i, props ) );
522 b.push_back( make( wxS(
"FOOTPRINT" ), idB, i, i, props ) );
526 const auto start = std::chrono::steady_clock::now();
528 const auto elapsed = std::chrono::steady_clock::now() - start;
530 const double seconds = std::chrono::duration<double>( elapsed ).count();
533 BOOST_CHECK( seconds < 5.0 );
549 auto props = std::vector<std::pair<wxString, std::string>>{
550 { wxS(
"lib_id" ),
"Device:R" },
551 { wxS(
"reference" ),
"R1" } };
554 std::vector<ITEM_DESCRIPTOR> a = { make( wxS(
"FOOTPRINT" ), idA1, 0, 0, props ) };
555 std::vector<ITEM_DESCRIPTOR> b = { make( wxS(
"FOOTPRINT" ), idB1, 500, 500, props ) };
558 config.positionTolerance = 1000;
Reconciles item identity across two snapshots of the same document.
RECONCILIATION Reconcile(const std::vector< ITEM_DESCRIPTOR > &aA, const std::vector< ITEM_DESCRIPTOR > &aB) const
const CONFIG & GetConfig() const
void SetConfig(const CONFIG &aConfig)
double ScoreSimilarity(const ITEM_DESCRIPTOR &aA, const ITEM_DESCRIPTOR &aB) const
Compute the similarity score between two items of the same type.
static void SeedGenerator(unsigned int aSeed)
Re-initialize the UUID generator with a given seed (for testing or QA purposes)
double similarityThreshold
Descriptor used by the identity reconciler to compare items across two documents.
std::vector< std::pair< wxString, std::string > > keyProps
Maps every item in document A to either a peer in document B or to "only-in-A", and vice versa.
std::set< KIID_PATH > aOnly
std::map< KIID_PATH, KIID_PATH > aToB
std::size_t similarityMatches
std::set< KIID_PATH > bOnly
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DirectUuidMatch)
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I