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.
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")