24#include <boost/test/unit_test.hpp>
53using ItemStore = std::vector<TestItem>;
54using ItemMap = std::map<wxString, const TestItem*>;
57ItemMap MakeMap( ItemStore& aStore )
61 for(
const TestItem& it : aStore )
77const TestItem* Find(
const std::vector<std::unique_ptr<TestItem>>& aOut,
const wxString& aName )
79 for(
const auto&
up : aOut )
81 if(
up &&
up->name == aName )
96 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
97 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
98 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
103 ItemMap ancMap = MakeMap( anc );
105 ItemMap oursMap = MakeMap( ours );
107 ItemMap theirsMap = MakeMap( theirs );
110 auto out = applier.
Apply();
121 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
122 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
123 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
128 ItemMap ancMap = MakeMap( anc );
130 ItemMap oursMap = MakeMap( ours );
132 ItemMap theirsMap = MakeMap( theirs );
135 auto out = applier.
Apply();
145 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
146 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
147 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
152 ItemMap ancMap = MakeMap( anc );
154 ItemMap oursMap = MakeMap( ours );
156 ItemMap theirsMap = MakeMap( theirs );
159 auto out = applier.
Apply();
171 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
173 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
178 ItemMap ancMap = MakeMap( anc );
180 ItemMap oursMap = MakeMap( ours );
182 ItemMap theirsMap = MakeMap( theirs );
185 auto out = applier.
Apply();
194 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
195 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
196 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
201 ItemMap ancMap = MakeMap( anc );
203 ItemMap oursMap = MakeMap( ours );
205 ItemMap theirsMap = MakeMap( theirs );
208 auto out = applier.
Apply();
218 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
219 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
220 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
225 ItemMap ancMap = MakeMap( anc );
227 ItemMap oursMap = MakeMap( ours );
229 ItemMap theirsMap = MakeMap( theirs );
232 auto out = applier.
Apply();
245 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
246 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
251 ItemMap ancMap = MakeMap( anc );
253 ItemMap oursMap = MakeMap( ours );
255 ItemMap theirsMap = MakeMap( theirs );
258 auto out = applier.
Apply();
273 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
278 ItemMap ancMap = MakeMap( anc );
280 ItemMap oursMap = MakeMap( ours );
282 ItemMap theirsMap = MakeMap( theirs );
285 auto out = applier.
Apply();
297 ItemStore anc, ours, theirs;
302 ItemMap ancMap = MakeMap( anc );
304 ItemMap oursMap = MakeMap( ours );
306 ItemMap theirsMap = MakeMap( theirs );
309 auto out = applier.
Apply();
320 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
321 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
322 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
327 ItemMap ancMap = MakeMap( anc );
329 ItemMap oursMap = MakeMap( ours );
331 ItemMap theirsMap = MakeMap( theirs );
334 auto out = applier.
Apply();
347 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
348 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
349 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
354 ItemMap ancMap = MakeMap( anc );
355 ItemMap oursMap = MakeMap( ours );
356 ItemMap theirsMap = MakeMap( theirs );
361 return std::make_unique<TestItem>( TestItem{ wxS(
"R" ),
364 auto out = applier.
Apply();
377 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
378 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) } };
383 ItemMap ancMap = MakeMap( anc );
385 ItemMap oursMap = MakeMap( ours );
387 ItemMap theirsMap = MakeMap( theirs );
390 auto out = applier.
Apply();
402 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
403 ItemStore ours, theirs;
408 ItemMap ancMap = MakeMap( anc );
410 ItemMap oursMap = MakeMap( ours );
412 ItemMap theirsMap = MakeMap( theirs );
415 auto out = applier.
Apply();
426 ItemStore anc{ { wxS(
"C" ), wxS(
"anc" ) }, { wxS(
"A" ), wxS(
"anc" ) },
427 { wxS(
"B" ), wxS(
"anc" ) } };
428 ItemStore ours, theirs;
432 ItemMap ancMap = MakeMap( anc );
434 ItemMap oursMap = MakeMap( ours );
436 ItemMap theirsMap = MakeMap( theirs );
439 auto out = applier.
Apply();
452 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
453 ItemStore ours, theirs;
457 ItemMap ancMap = MakeMap( anc );
459 ItemMap oursMap = MakeMap( ours );
461 ItemMap theirsMap = MakeMap( theirs );
464 auto out = applier.
Apply();
467 anc[0].side = wxS(
"MUTATED" );
477 { wxS(
"Keep" ), wxS(
"anc" ) },
478 { wxS(
"DelMe" ), wxS(
"anc" ) },
479 { wxS(
"Anc" ), wxS(
"anc" ) },
480 { wxS(
"MergeProps" ), wxS(
"anc" ) },
483 { wxS(
"Keep" ), wxS(
"ours" ) },
484 { wxS(
"DelMe" ), wxS(
"ours" ) },
485 { wxS(
"Anc" ), wxS(
"ours" ) },
486 { wxS(
"OursOnly" ), wxS(
"ours" ) },
487 { wxS(
"MergeProps" ), wxS(
"ours" ) },
490 { wxS(
"Keep" ), wxS(
"theirs" ) },
491 { wxS(
"TheirsOnly" ), wxS(
"theirs" ) },
492 { wxS(
"MergeProps" ), wxS(
"theirs" ) },
503 ItemMap ancMap = MakeMap( anc );
505 ItemMap oursMap = MakeMap( ours );
507 ItemMap theirsMap = MakeMap( theirs );
510 auto out = applier.
Apply();
524 const TestItem* keep = Find( out, wxS(
"Keep" ) );
525 const TestItem* anc_pick = Find( out, wxS(
"Anc" ) );
526 const TestItem* ours_only = Find( out, wxS(
"OursOnly" ) );
527 const TestItem* theirs_one = Find( out, wxS(
"TheirsOnly" ) );
528 const TestItem* merge = Find( out, wxS(
"MergeProps" ) );
538 BOOST_CHECK( theirs_one->side == wxS(
"theirs" ) );
540 BOOST_CHECK( Find( out, wxS(
"DelMe" ) ) ==
nullptr );
550 ItemStore anc{ { wxS(
"R" ), wxS(
"anc" ) } };
552 ItemStore theirs{ { wxS(
"R" ), wxS(
"theirs" ) } };
557 ItemMap ancMap = MakeMap( anc );
558 ItemMap oursMap = MakeMap( ours );
559 ItemMap theirsMap = MakeMap( theirs );
561 auto out = applier.
Apply();
575 ItemStore anc{ { wxS(
"A" ), wxS(
"anc" ) }, { wxS(
"B" ), wxS(
"anc" ) },
576 { wxS(
"C" ), wxS(
"anc" ) } };
577 ItemStore ours{ { wxS(
"A" ), wxS(
"ours" ) } };
578 ItemStore theirs{ { wxS(
"B" ), wxS(
"theirs" ) } };
585 ItemMap ancMap = MakeMap( anc );
586 ItemMap oursMap = MakeMap( ours );
587 ItemMap theirsMap = MakeMap( theirs );
602 ItemStore anc{ { wxS(
"M" ), wxS(
"anc" ) } };
603 ItemStore ours{ { wxS(
"R" ), wxS(
"ours" ) }, { wxS(
"M" ), wxS(
"ours" ) } };
604 ItemStore theirs{ { wxS(
"M" ), wxS(
"theirs" ) } };
610 ItemMap ancMap = MakeMap( anc );
611 ItemMap oursMap = MakeMap( ours );
612 ItemMap theirsMap = MakeMap( theirs );
Materialize a MERGE_PLAN into a merged name-keyed library.
const REPORT & GetReport() const
std::vector< std::unique_ptr< ITEM > > Apply()
static std::vector< PENDING_PROPERTY > plan(const EDA_ITEM &aSource, const EDA_ITEM &aTarget, const std::set< wxString > &aEnabledKeys)
Target properties to write, paired with values read off the source.
ITEM_RES
Resolution kind for a whole item.
KIID_PATH LibraryItemKiidPath(const wxString &aName)
Build a deterministic synthetic KIID_PATH from a library item name (symbol name or footprint name).
std::size_t mergePropsFallback
std::size_t itemsTakenOurs
std::size_t itemsTakenTheirs
std::size_t itemsTakenAncestor
std::vector< KIID_PATH > mergePropsFallbackIds
Item IDs (KIID_PATH from LibraryItemKiidPath) for resolutions that the applier silently downgraded (c...
Result of planning a 3-way merge.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TakeOurs_PicksOursSide)