20#include <boost/test/unit_test.hpp>
34 BOOST_CHECK( part.
name.empty() );
35 BOOST_CHECK( part.
decal.empty() );
37 BOOST_CHECK( part.
value.empty() );
71 std::string decal_string =
"RESISTOR_0603";
74 std::vector<std::string> alternates;
80 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
82 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
91 alternates.push_back( decal_name );
97 std::string last_decal = decal_string.substr( pos );
100 primary = last_decal;
102 alternates.push_back( last_decal );
105 BOOST_CHECK( alternates.empty() );
111 std::string decal_string =
"DIP8:SOIC8";
114 std::vector<std::string> alternates;
117 size_t colon_pos = 0;
120 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
122 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
126 primary = decal_name;
131 alternates.push_back( decal_name );
137 std::string last_decal = decal_string.substr( pos );
140 primary = last_decal;
142 alternates.push_back( last_decal );
145 BOOST_REQUIRE_EQUAL( alternates.size(), 1 );
152 std::string decal_string =
"DIP8:SOIC8:QFN8";
155 std::vector<std::string> alternates;
158 size_t colon_pos = 0;
161 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
163 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
167 primary = decal_name;
172 alternates.push_back( decal_name );
178 std::string last_decal = decal_string.substr( pos );
181 primary = last_decal;
183 alternates.push_back( last_decal );
186 BOOST_REQUIRE_EQUAL( alternates.size(), 2 );
194 std::string decal_string =
"PKG1:PKG2:PKG3:PKG4:PKG5";
197 std::vector<std::string> alternates;
200 size_t colon_pos = 0;
203 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
205 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
209 primary = decal_name;
214 alternates.push_back( decal_name );
220 std::string last_decal = decal_string.substr( pos );
223 primary = last_decal;
225 alternates.push_back( last_decal );
228 BOOST_REQUIRE_EQUAL( alternates.size(), 4 );
267 BOOST_CHECK( pour.
net_name.empty() );
271 BOOST_CHECK( pour.
points.empty() );
319 instance.
glued =
true;
324 BOOST_CHECK_CLOSE( instance.
location.
x, 1000.0, 0.001 );
325 BOOST_CHECK_CLOSE( instance.
location.
y, 2000.0, 0.001 );
326 BOOST_CHECK_CLOSE( instance.
rotation, 90.0, 0.001 );
334 BOOST_CHECK( block.
name.empty() );
339 BOOST_CHECK( block.
nets.empty() );
347 block.
name =
"MEMORY_BLOCK";
358 block.
nets.push_back( net1 );
363 block.
nets.push_back( net2 );
375 BOOST_REQUIRE_EQUAL( block.
part_names.size(), 3 );
379 BOOST_REQUIRE_EQUAL( block.
nets.size(), 2 );
384 BOOST_REQUIRE_EQUAL( block.
instances.size(), 1 );
392 std::map<std::string, REUSE_BLOCK> blocks;
395 memBlock.
name =
"MEMORY";
398 blocks[
"MEMORY"] = memBlock;
401 pwrBlock.
name =
"POWER";
405 blocks[
"POWER"] = pwrBlock;
408 std::map<std::string, std::string> partToBlockMap;
410 for(
const auto& [blockName, block] : blocks )
412 for(
const std::string& partName : block.part_names )
414 partToBlockMap[partName] = blockName;
418 BOOST_REQUIRE_EQUAL( partToBlockMap.size(), 5 );
430 std::map<std::string, REUSE_BLOCK> blocks;
431 std::map<std::string, std::string> partToBlockMap;
433 for(
const auto& [blockName, block] : blocks )
435 for(
const std::string& partName : block.part_names )
437 partToBlockMap[partName] = blockName;
441 BOOST_CHECK( partToBlockMap.empty() );
449 emptyBlock.
name =
"EMPTY";
452 blockWithParts.
name =
"WITH_PARTS";
456 blockWithInstances.
name =
"WITH_INSTANCES";
459 blockWithInstances.
instances.push_back( inst );
463 bool createPartsGroup = !blockWithParts.
instances.empty() || !blockWithParts.
part_names.empty();
464 bool createInstanceGroup = !blockWithInstances.
instances.empty() || !blockWithInstances.
part_names.empty();
475 BOOST_CHECK( cluster.
name.empty() );
477 BOOST_CHECK( cluster.
net_names.empty() );
485 cluster.
name =
"MEMORY_BUS";
496 BOOST_REQUIRE_EQUAL( cluster.
net_names.size(), 3 );
510 std::string netName =
"DATA0";
511 std::string segRef =
"DATA0.1";
512 std::string segRefComplex =
"NET_123.45";
514 bool netNameHasDot = netName.find(
'.' ) != std::string::npos;
515 bool segRefHasDot = segRef.find(
'.' ) != std::string::npos;
516 bool segRefComplexHasDot = segRefComplex.find(
'.' ) != std::string::npos;
527 BOOST_CHECK(
tp.type.empty() );
531 BOOST_CHECK(
tp.net_name.empty() );
532 BOOST_CHECK(
tp.symbol_name.empty() );
544 tp.symbol_name =
"TESTVIATHRU";
547 BOOST_CHECK_CLOSE(
tp.x, 7000.0, 0.001 );
548 BOOST_CHECK_CLOSE(
tp.y, 3450.0, 0.001 );
563 tp.symbol_name =
"U1.3";
589 BOOST_CHECK( dim.
name.empty() );
593 BOOST_CHECK( dim.
points.empty() );
594 BOOST_CHECK( dim.
text.empty() );
613 dim.
points.push_back( { 0.0, 0.0 } );
614 dim.
points.push_back( { 1050.0, 0.0 } );
615 dim.
points.push_back( { 1050.0, 100.0 } );
618 BOOST_CHECK_CLOSE( dim.
x, 1000.0, 0.001 );
619 BOOST_CHECK_CLOSE( dim.
y, 2000.0, 0.001 );
623 BOOST_CHECK_CLOSE( dim.
text_width, 8.0, 0.001 );
624 BOOST_CHECK_CLOSE( dim.
rotation, 90.0, 0.001 );
632 std::string dimName1 =
"DIM001";
633 std::string dimName2 =
"DIM_BOARD_WIDTH";
634 std::string nonDimName =
"OUTLINE";
636 BOOST_CHECK( dimName1.rfind(
"DIM", 0 ) == 0 );
637 BOOST_CHECK( dimName2.rfind(
"DIM", 0 ) == 0 );
638 BOOST_CHECK( nonDimName.rfind(
"DIM", 0 ) != 0 );
692 BOOST_CHECK( nc.
name.empty() );
706 nc.
name =
"HighSpeed";
718 BOOST_CHECK_CLOSE( nc.
clearance, 12.0, 0.001 );
720 BOOST_CHECK_CLOSE( nc.
via_size, 30.0, 0.001 );
721 BOOST_CHECK_CLOSE( nc.
via_drill, 15.0, 0.001 );
734 BOOST_CHECK( dp.
name.empty() );
745 dp.
name =
"USB_DATA";
754 BOOST_CHECK_CLOSE( dp.
gap, 8.0, 0.001 );
755 BOOST_CHECK_CLOSE( dp.
width, 10.0, 0.001 );
General utilities for PCB file IO for QA programs.
std::vector< std::string > segment_refs
std::vector< std::string > net_names
double silk_clearance
SILKCLEAR.
double default_track_width
DEFAULTTRACKWID.
double default_via_drill
DEFAULTVIADRILL.
double min_track_width
MINTRACKWID.
double min_via_size
MINVIASIZE.
double min_via_drill
MINVIADRILL.
double min_clearance
MINCLEAR.
double default_via_size
DEFAULTVIASIZE.
double default_clearance
DEFAULTCLEAR.
double hole_to_hole
HOLEHOLE.
double mask_clearance
MASKCLEAR.
std::vector< POINT > points
Measurement endpoints.
double via_drill
VIADRILL.
double clearance
CLEARANCE.
std::vector< std::string > net_names
double track_width
TRACKWIDTH.
double diff_pair_width
DIFFPAIRWIDTH.
double diff_pair_gap
DIFFPAIRGAP.
double thermal_line_width
THERLINEWID, THT.
double thermal_smd_width
THERSMDWID, SMD.
double thermal_min_clearance
STMINCLEAR.
int thermal_flags
THERFLAGS.
int thermal_min_spokes
STMINSPOKES.
std::string decal
Primary decal (first in colon-separated list)
std::vector< std::string > alternate_decals
Remaining decals after ':' splits.
bool is_cutout
POCUT piece.
std::string owner_pour
Parent pour, 7th header field.
std::vector< ARC_POINT > points
A reuse block definition containing parts and routes that can be instantiated.
std::vector< REUSE_NET > nets
std::string net_naming
Default scheme.
std::string part_naming
Default scheme.
std::vector< std::string > part_names
std::vector< REUSE_INSTANCE > instances
Placements of this block.
std::string instance_name
std::string part_naming
May be multi-word like "PREFIX pref".
std::string net_naming
May be multi-word like "SUFFIX suf".
std::string name
Original net name from reuse definition.
bool merge
Merge nets vs rename.
int side
0=through, 1=top, 2=bottom
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(Part_DefaultConstruction)
BOOST_CHECK_EQUAL(result, "25.4")