20#include <boost/test/unit_test.hpp>
40static const char*
BOARD_FILE =
"net_chains/length_with_chain.kicad_pcb";
46static const char*
DRU_TEXT = R
"KICAD((version 1)
49 (condition "A.NetClass == 'Default'")
50 (constraint length (min 0mm) (max 5mm))
51 (constraint net_chain_length (min 0mm) (max 200mm))
61 namespace fs = std::filesystem;
65 fs::path druPath = tmpDir.
Path() /
"len_chain.kicad_dru";
68 std::ofstream druOut( druPath );
74 board->BuildConnectivity();
77 NETINFO_ITEM* chainNet = board->FindNet( wxS(
"/CHAIN_NET" ) );
81 NETINFO_ITEM* plainNet = board->FindNet( wxS(
"/PLAIN_NET" ) );
87 auto drcEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
88 wxFileName ruleFile( druPath.string() );
89 drcEngine->InitEngine( ruleFile );
100 std::vector<DRC_ITEM> lengthViolations;
102 drcEngine->SetViolationHandler(
103 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
107 lengthViolations.push_back( *aItem );
114 BOOST_CHECK_MESSAGE( lengthViolations.size() >= 2,
115 "Expected per-net length violations on both chain and plain nets, got "
116 << lengthViolations.size() );
118 bool chainNetFlagged =
false;
119 bool plainNetFlagged =
false;
121 for(
const DRC_ITEM& item : lengthViolations )
123 for(
const KIID&
id : item.GetIDs() )
132 if( bci->GetNetCode() == chainNet->
GetNetCode() )
133 chainNetFlagged =
true;
135 if( bci->GetNetCode() == plainNet->
GetNetCode() )
136 plainNetFlagged =
true;
141 BOOST_CHECK_MESSAGE( chainNetFlagged,
"Length violation missing for chain-bearing net" );
142 BOOST_CHECK_MESSAGE( plainNetFlagged,
"Length violation missing for non-chain net" );
145 fs::remove( druPath, ec );
General utilities for PCB file IO for QA programs.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
std::map< int, SEVERITY > m_DRCSeverities
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
const std::filesystem::path & Path() const
Get the path to the temporary directory as a std::filesystem::path.
Handle the data for a net.
const wxString & GetNetChain() const
void SetNetChain(const wxString &aNetChain)
A PCB_IO derivation for saving and loading Pcbnew s-expression formatted files.
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into new BOA...
@ DRCE_LIB_FOOTPRINT_ISSUES
@ DRCE_DRILL_OUT_OF_RANGE
@ DRCE_LENGTH_OUT_OF_RANGE
@ DRCE_LIB_FOOTPRINT_MISMATCH
std::string GetPcbnewTestDataDir()
Utility which returns a path to the data directory where the test board files are stored.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
static const char * BOARD_FILE
static const char * DRU_TEXT
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I