24#include <boost/test/unit_test.hpp>
38 BOOST_CHECK( part.
name.empty() );
39 BOOST_CHECK( part.
decal.empty() );
41 BOOST_CHECK( part.
value.empty() );
75 std::string decal_string =
"RESISTOR_0603";
78 std::vector<std::string> alternates;
84 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
86 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
95 alternates.push_back( decal_name );
101 std::string last_decal = decal_string.substr( pos );
104 primary = last_decal;
106 alternates.push_back( last_decal );
109 BOOST_CHECK( alternates.empty() );
115 std::string decal_string =
"DIP8:SOIC8";
118 std::vector<std::string> alternates;
121 size_t colon_pos = 0;
124 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
126 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
130 primary = decal_name;
135 alternates.push_back( decal_name );
141 std::string last_decal = decal_string.substr( pos );
144 primary = last_decal;
146 alternates.push_back( last_decal );
149 BOOST_REQUIRE_EQUAL( alternates.size(), 1 );
156 std::string decal_string =
"DIP8:SOIC8:QFN8";
159 std::vector<std::string> alternates;
162 size_t colon_pos = 0;
165 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
167 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
171 primary = decal_name;
176 alternates.push_back( decal_name );
182 std::string last_decal = decal_string.substr( pos );
185 primary = last_decal;
187 alternates.push_back( last_decal );
190 BOOST_REQUIRE_EQUAL( alternates.size(), 2 );
198 std::string decal_string =
"PKG1:PKG2:PKG3:PKG4:PKG5";
201 std::vector<std::string> alternates;
204 size_t colon_pos = 0;
207 while( ( colon_pos = decal_string.find(
':', pos ) ) != std::string::npos )
209 std::string decal_name = decal_string.substr( pos, colon_pos - pos );
213 primary = decal_name;
218 alternates.push_back( decal_name );
224 std::string last_decal = decal_string.substr( pos );
227 primary = last_decal;
229 alternates.push_back( last_decal );
232 BOOST_REQUIRE_EQUAL( alternates.size(), 4 );
271 BOOST_CHECK( pour.
net_name.empty() );
275 BOOST_CHECK( pour.
points.empty() );
323 instance.
glued =
true;
328 BOOST_CHECK_CLOSE( instance.
location.
x, 1000.0, 0.001 );
329 BOOST_CHECK_CLOSE( instance.
location.
y, 2000.0, 0.001 );
330 BOOST_CHECK_CLOSE( instance.
rotation, 90.0, 0.001 );
338 BOOST_CHECK( block.
name.empty() );
343 BOOST_CHECK( block.
nets.empty() );
351 block.
name =
"MEMORY_BLOCK";
362 block.
nets.push_back( net1 );
367 block.
nets.push_back( net2 );
379 BOOST_REQUIRE_EQUAL( block.
part_names.size(), 3 );
383 BOOST_REQUIRE_EQUAL( block.
nets.size(), 2 );
388 BOOST_REQUIRE_EQUAL( block.
instances.size(), 1 );
396 std::map<std::string, REUSE_BLOCK> blocks;
399 memBlock.
name =
"MEMORY";
402 blocks[
"MEMORY"] = memBlock;
405 pwrBlock.
name =
"POWER";
409 blocks[
"POWER"] = pwrBlock;
412 std::map<std::string, std::string> partToBlockMap;
414 for(
const auto& [blockName, block] : blocks )
416 for(
const std::string& partName : block.part_names )
418 partToBlockMap[partName] = blockName;
422 BOOST_REQUIRE_EQUAL( partToBlockMap.size(), 5 );
434 std::map<std::string, REUSE_BLOCK> blocks;
435 std::map<std::string, std::string> partToBlockMap;
437 for(
const auto& [blockName, block] : blocks )
439 for(
const std::string& partName : block.part_names )
441 partToBlockMap[partName] = blockName;
445 BOOST_CHECK( partToBlockMap.empty() );
453 emptyBlock.
name =
"EMPTY";
456 blockWithParts.
name =
"WITH_PARTS";
460 blockWithInstances.
name =
"WITH_INSTANCES";
463 blockWithInstances.
instances.push_back( inst );
467 bool createPartsGroup = !blockWithParts.
instances.empty() || !blockWithParts.
part_names.empty();
468 bool createInstanceGroup = !blockWithInstances.
instances.empty() || !blockWithInstances.
part_names.empty();
479 BOOST_CHECK( cluster.
name.empty() );
481 BOOST_CHECK( cluster.
net_names.empty() );
489 cluster.
name =
"MEMORY_BUS";
500 BOOST_REQUIRE_EQUAL( cluster.
net_names.size(), 3 );
514 std::string netName =
"DATA0";
515 std::string segRef =
"DATA0.1";
516 std::string segRefComplex =
"NET_123.45";
518 bool netNameHasDot = netName.find(
'.' ) != std::string::npos;
519 bool segRefHasDot = segRef.find(
'.' ) != std::string::npos;
520 bool segRefComplexHasDot = segRefComplex.find(
'.' ) != std::string::npos;
531 BOOST_CHECK(
tp.type.empty() );
535 BOOST_CHECK(
tp.net_name.empty() );
536 BOOST_CHECK(
tp.symbol_name.empty() );
548 tp.symbol_name =
"TESTVIATHRU";
551 BOOST_CHECK_CLOSE(
tp.x, 7000.0, 0.001 );
552 BOOST_CHECK_CLOSE(
tp.y, 3450.0, 0.001 );
567 tp.symbol_name =
"U1.3";
593 BOOST_CHECK( dim.
name.empty() );
597 BOOST_CHECK( dim.
points.empty() );
598 BOOST_CHECK( dim.
text.empty() );
617 dim.
points.push_back( { 0.0, 0.0 } );
618 dim.
points.push_back( { 1050.0, 0.0 } );
619 dim.
points.push_back( { 1050.0, 100.0 } );
622 BOOST_CHECK_CLOSE( dim.
x, 1000.0, 0.001 );
623 BOOST_CHECK_CLOSE( dim.
y, 2000.0, 0.001 );
627 BOOST_CHECK_CLOSE( dim.
text_width, 8.0, 0.001 );
628 BOOST_CHECK_CLOSE( dim.
rotation, 90.0, 0.001 );
636 std::string dimName1 =
"DIM001";
637 std::string dimName2 =
"DIM_BOARD_WIDTH";
638 std::string nonDimName =
"OUTLINE";
640 BOOST_CHECK( dimName1.rfind(
"DIM", 0 ) == 0 );
641 BOOST_CHECK( dimName2.rfind(
"DIM", 0 ) == 0 );
642 BOOST_CHECK( nonDimName.rfind(
"DIM", 0 ) != 0 );
696 BOOST_CHECK( nc.
name.empty() );
710 nc.
name =
"HighSpeed";
722 BOOST_CHECK_CLOSE( nc.
clearance, 12.0, 0.001 );
724 BOOST_CHECK_CLOSE( nc.
via_size, 30.0, 0.001 );
725 BOOST_CHECK_CLOSE( nc.
via_drill, 15.0, 0.001 );
738 BOOST_CHECK( dp.
name.empty() );
749 dp.
name =
"USB_DATA";
758 BOOST_CHECK_CLOSE( dp.
gap, 8.0, 0.001 );
759 BOOST_CHECK_CLOSE( dp.
width, 10.0, 0.001 );
General utilities for PCB file IO for QA programs.
A cluster of related route segments that should be grouped together.
std::vector< std::string > segment_refs
References to route segments in cluster.
std::string name
Cluster name/identifier.
std::vector< std::string > net_names
Nets belonging to this cluster.
Design rule definitions from PCB section.
double silk_clearance
Minimum silkscreen clearance (SILKCLEAR)
double default_track_width
Default track width (DEFAULTTRACKWID)
double default_via_drill
Default via drill diameter (DEFAULTVIADRILL)
double min_track_width
Minimum track width (MINTRACKWID)
double min_via_size
Minimum via outer diameter (MINVIASIZE)
double min_via_drill
Minimum via drill diameter (MINVIADRILL)
double min_clearance
Minimum copper clearance (MINCLEAR)
double default_via_size
Default via outer diameter (DEFAULTVIASIZE)
double default_clearance
Default copper clearance (DEFAULTCLEAR)
double hole_to_hole
Minimum hole-to-hole spacing (HOLEHOLE)
double mask_clearance
Solder mask clearance (MASKCLEAR)
Differential pair definition.
std::string positive_net
Positive net name.
std::string negative_net
Negative net name.
double gap
Spacing between traces.
std::string name
Pair name.
A dimension annotation for measurement display.
std::string name
Dimension identifier.
double text_width
Text width.
double y
Origin Y coordinate.
double rotation
Text rotation angle.
double x
Origin X coordinate.
std::string text
Dimension text/value.
int layer
Layer for dimension graphics.
double text_height
Text height.
std::vector< POINT > points
Dimension geometry points (measurement endpoints)
Net class definition with routing constraints.
double via_drill
Via drill diameter (VIADRILL)
double clearance
Copper clearance (CLEARANCE)
std::vector< std::string > net_names
Nets assigned to this class.
double track_width
Track width (TRACKWIDTH)
std::string name
Net class name.
double diff_pair_width
Differential pair width (DIFFPAIRWIDTH)
double diff_pair_gap
Differential pair gap (DIFFPAIRGAP)
double via_size
Via diameter (VIASIZE)
double thermal_line_width
Thermal line width for THT (THERLINEWID)
double thermal_smd_width
Thermal line width for SMD (THERSMDWID)
double thermal_min_clearance
Starved thermal minimum clearance (STMINCLEAR)
int thermal_flags
Thermal relief flags (THERFLAGS)
int thermal_min_spokes
Starved thermal minimum spokes (STMINSPOKES)
std::string decal
Primary decal (first in colon-separated list)
std::vector< std::string > alternate_decals
Alternate decals (remaining after ':' splits)
bool is_cutout
True if this is a cutout (POCUT) piece.
std::string owner_pour
Name of parent pour (7th field in header)
std::vector< ARC_POINT > points
Pour outline, may include arc segments.
A reuse block definition containing parts and routes that can be instantiated.
std::vector< REUSE_NET > nets
Nets contained in this block with merge flags.
std::string net_naming
Default net naming scheme.
long timestamp
Creation/modification timestamp.
std::string part_naming
Default part naming scheme.
std::vector< std::string > part_names
Parts contained in this block.
std::vector< REUSE_INSTANCE > instances
Placements of this block.
std::string name
Block type name.
std::string instance_name
Instance name.
std::string part_naming
Part naming scheme (may be multi-word like "PREFIX pref")
std::string net_naming
Net naming scheme (may be multi-word like "SUFFIX suf")
bool glued
True if glued in place.
POINT location
Placement location.
double rotation
Rotation angle in degrees.
A reuse block instance placement.
std::string name
Original net name from reuse definition.
bool merge
True to merge nets, false to rename.
A test point definition for manufacturing/testing access.
int side
Probe 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")