59 const std::string& aLibName =
"TestPart" )
90 std::map<int, std::vector<SCH_REFERENCE>> refNumberMap;
94 std::vector<SCH_REFERENCE> refs;
99 refNumberMap[refNum] = refs;
114 BOOST_CHECK( tracker.
Contains( resultRefDes ) );
129 BOOST_CHECK( e.
m_unit != unit );
139 "Completely unused reference - empty units",
140 "U",
"LM358",
"OpAmp_Dual",
148 "Completely unused reference - with units",
149 "U",
"LM358",
"OpAmp_Dual",
157 "Skip currently in use reference",
158 "U",
"LM358",
"OpAmp_Dual",
159 { { 1, { {
"LM358",
"OpAmp_Dual", 1 } } } },
166 "Units available in currently used reference",
167 "U",
"LM358",
"OpAmp_Dual",
168 { { 1, { {
"LM358",
"OpAmp_Dual", 3 }, {
"LM358",
"OpAmp_Dual", 4 } } } },
175 "Different value conflict",
176 "U",
"LM358",
"OpAmp_Dual",
177 { { 1, { {
"LM741",
"OpAmp_Dual", 1 } } } },
184 "Previously used reference in tracker",
185 "U",
"LM358",
"OpAmp_Dual",
193 "Min value higher than available",
194 "U",
"LM358",
"OpAmp_Dual",
195 { { 5, { {
"LM358",
"OpAmp_Dual", 1 } } } },
202 "Negative units filtered out",
203 "U",
"LM358",
"OpAmp_Dual",
211 "Complex scenario with gaps",
212 "IC",
"74HC00",
"Logic_Gate",
213 { { 2, { {
"74HC00",
"Logic_Gate", 1 } } },
214 { 4, { {
"74HC00",
"Logic_Gate", 2 } } } },
224 "Units available - no conflicts",
225 "U",
"LM358",
"OpAmp_Dual",
226 { { 1, { {
"LM358",
"OpAmp_Dual", 3 }, {
"LM358",
"OpAmp_Dual", 4 } } } },
233 "Units conflict - same unit requested",
234 "U",
"LM358",
"OpAmp_Dual",
235 { { 1, { {
"LM358",
"OpAmp_Dual", 1 }, {
"LM358",
"OpAmp_Dual", 2 } } } },
242 "Value mismatch - can't share reference",
243 "R",
"1k",
"Resistor",
244 { { 1, { {
"2k",
"Resistor", 1 } } } },
251 "Library mismatch - can't share reference",
252 "U",
"LM358",
"OpAmp_Dual",
253 { { 1, { {
"LM358",
"OpAmp_Single", 1 } } } },
260 "Empty existing units - should be available",
261 "IC",
"74HC00",
"Logic_Gate",
269 "Negative units filtered out with occupied neighbour",
270 "U",
"LM324",
"OpAmp_Quad",
271 { { 1, { {
"LM324",
"OpAmp_Quad", 2 } } } },
278 "All units conflict",
279 "U",
"LM324",
"OpAmp_Quad",
280 { { 1, { {
"LM324",
"OpAmp_Quad", 1 }, {
"LM324",
"OpAmp_Quad", 2 },
281 {
"LM324",
"OpAmp_Quad", 3 }, {
"LM324",
"OpAmp_Quad", 4 } } } },
288 "Partial conflict with mixed values",
289 "R",
"1k",
"Resistor",
290 { { 1, { {
"1k",
"Resistor", 1 } } } },
297 "Complex multi-unit scenario",
298 "U",
"LM339",
"Comparator_Quad",
299 { { 1, { {
"LM339",
"Comparator_Quad", 1 }, {
"LM339",
"Comparator_Quad", 3 } } } },
312 runTestCase( testCase );
321 std::map<int, std::vector<SCH_REFERENCE>> emptyMap;
322 std::vector<int> emptyUnits;
327 BOOST_CHECK( tracker.
Contains(
"R1" ) );
335 std::vector<int> mixedUnits = {-1, 1, -5, 2};
336 SCH_REFERENCE testRef2 = createTestReference(
"C",
"100nF", 1 );
346 SCH_REFERENCE testRef = createTestReference(
"U",
"LM358", 1 );
349 std::map<int, std::vector<SCH_REFERENCE>> refNumberMap;
350 refNumberMap[1] = { createTestReference(
"U",
"LM358", 1),
351 createTestReference(
"U",
"LM358", 2) };
352 refNumberMap[3] = { createTestReference(
"U",
"LM358", 1) };
355 std::vector<int> requiredUnits = {1, 2};
364 BOOST_CHECK( tracker.
Contains(
"U2" ) );
367 std::vector<int> requiredUnits2 = {3, 4};
368 refNumberMap[3] = { createTestReference(
"U",
"LM358", 1) };
374 SCH_REFERENCE differentValueRef = createTestReference(
"U",
"LM741", 1 );
375 refNumberMap[4] = { createTestReference(
"U",
"LM358", 1) };
386 SCH_REFERENCE testRef = createTestReference(
"U",
"LM358", 1 );
387 std::map<int, std::vector<SCH_REFERENCE>> emptyMap;
388 std::vector<int> requiredUnits = {1, 2};
393 BOOST_CHECK( tracker.
Contains(
"U1" ) );
398 BOOST_CHECK( tracker.
Contains(
"U2" ) );
401 std::map<int, std::vector<SCH_REFERENCE>> conflictMap;
402 conflictMap[3] = { createTestReference(
"U",
"LM358", 1) };
416 BOOST_CHECK( tracker.
Contains(
"U1" ) );
417 BOOST_CHECK( tracker.
Contains(
"U3" ) );
418 BOOST_CHECK( !tracker.
Contains(
"U2" ) );
421 SCH_REFERENCE testRef = createTestReference(
"U",
"LM358", 1 );
422 std::map<int, std::vector<SCH_REFERENCE>> emptyMap;
423 std::vector<int> requiredUnits = {1, 2};
430 BOOST_CHECK( tracker.
Contains(
"U2" ) );
435 BOOST_CHECK( tracker.
Contains(
"U5" ) );
438 std::string serialized = tracker.
Serialize();
443 BOOST_CHECK( tracker2.
Contains(
"U1" ) );
444 BOOST_CHECK( tracker2.
Contains(
"U2" ) );
445 BOOST_CHECK( tracker2.
Contains(
"U3" ) );
446 BOOST_CHECK( tracker2.
Contains(
"U5" ) );
467 std::map<int, std::vector<SCH_REFERENCE>> emptyMap;
468 std::vector<int> requiredUnits = {1};
474 SCH_REFERENCE capacitorRef = createTestReference(
"C",
"100nF", 1 );
479 std::string serialized = tracker.
Serialize();
480 BOOST_CHECK( !serialized.empty() );
486 BOOST_CHECK( tracker2.
Contains(
"R1" ) );
487 BOOST_CHECK( tracker2.
Contains(
"R2" ) );
488 BOOST_CHECK( tracker2.
Contains(
"R3" ) );
489 BOOST_CHECK( tracker2.
Contains(
"C5" ) );
498 std::map<int, std::vector<SCH_REFERENCE>> conflictMap;
499 conflictMap[4] = { createTestReference(
"R",
"2k", 1) };
A generic fixture for loading schematics and associated settings for qa tests.
A logical library item identifier and consists of various portions much like a URI.
Class to efficiently track reference designators and provide next available designators.
bool Deserialize(const std::string &aData)
Deserialize tracker data from string representation.
int GetNextRefDesForUnits(const SCH_REFERENCE &aRef, const std::map< int, std::vector< SCH_REFERENCE > > &aRefNumberMap, const std::vector< int > &aRequiredUnits, int aMinValue)
Get the next available reference designator number for multi-unit symbols.
void SetReuseRefDes(bool aReuse)
bool Insert(const std::string &aRefDes)
Insert a reference designator into the tracker.
std::string Serialize() const
Serialize the tracker data to a compact string representation.
bool Contains(const std::string &aRefDes) const
Check if a reference designator exists in the tracker.
A helper to define a symbol's reference designator in a schematic.
void SetValue(const wxString &aValue)
void SetRef(const wxString &aReference)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetLibId(const LIB_ID &aName)
void runTestCase(const REFDES_UNITS_TEST_CASE &testCase)
std::vector< std::unique_ptr< SCH_SYMBOL > > m_symbols
SCH_REFERENCE createTestReference(const std::string &aRefPrefix, const std::string &aValue, int aUnit, const std::string &aLibName="TestPart")
SCH_REFERENCE holds a raw pointer to its symbol and CompareLibName dereferences it,...
One existing reference occupying a reference number.
std::vector< int > m_requiredUnits
std::string m_testRefLibName
std::map< int, std::vector< EXISTING_REF > > m_refNumberMap
std::string m_testRefValue
std::string m_testRefPrefix
std::vector< std::string > m_trackerPreloads
BOOST_AUTO_TEST_CASE(GetNextRefDesForUnits_BasicCases)
static const std::vector< REFDES_UNITS_TEST_CASE > refdesUnitsTestCases
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")