20#include <boost/test/unit_test.hpp>
38 BOOST_CHECK( a == b );
42 BOOST_CHECK( a != b );
46 BOOST_CHECK( a == b );
60 BOOST_CHECK( a != b );
64 BOOST_CHECK( a == b );
68 BOOST_CHECK( a != b );
72 BOOST_CHECK( a == b );
86 BOOST_CHECK( a != b );
87 BOOST_CHECK( b != a );
94 const wxString& aExpected )
101 if( resolved->GetName() == aExpected )
104 for(
NETCLASS* constituent : resolved->GetConstituentNetclasses() )
106 if( constituent && constituent->GetName() == aExpected )
121 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
122 std::map<wxString, std::shared_ptr<NETCLASS>> classes;
123 classes[wxS(
"HighSpeed" )] = highSpeed;
141 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
142 std::shared_ptr<NETCLASS> power = std::make_shared<NETCLASS>( wxS(
"Power" ),
false );
143 std::map<wxString, std::shared_ptr<NETCLASS>> classes;
144 classes[wxS(
"HighSpeed" )] = highSpeed;
145 classes[wxS(
"Power" )] = power;
187 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
188 std::shared_ptr<NETCLASS> power = std::make_shared<NETCLASS>( wxS(
"Power" ),
false );
189 std::map<wxString, std::shared_ptr<NETCLASS>> classes;
190 classes[wxS(
"HighSpeed" )] = highSpeed;
191 classes[wxS(
"Power" )] = power;
196 BOOST_CHECK( a == b );
200 BOOST_CHECK( a == b );
205 BOOST_CHECK( a == b );
209 BOOST_CHECK( a == b );
224 source.
SetNetChainClass( wxS(
"CHAIN_WITH_SPACES and: punctuation!" ), wxS(
"Power" ) );
233 nlohmann::json reparsed = nlohmann::json::parse( serialized );
245 static_cast<nlohmann::json&
>( reparsedInternals ) = reparsed;
251 BOOST_CHECK( sink.
GetNetChainClass( wxS(
"CHAIN_A" ) ) == wxS(
"Default" ) );
252 BOOST_CHECK( sink.
GetNetChainClass( wxS(
"CHAIN_B" ) ) == wxS(
"HighSpeed" ) );
253 BOOST_CHECK( sink.
GetNetChainClass( wxS(
"CHAIN_WITH_SPACES and: punctuation!" ) )
255 BOOST_CHECK( sink.
GetNetChainClass( wxS(
"Unicode_éèê" ) ) == wxS(
"RF_µwave" ) );
257 BOOST_CHECK( source == sink );
270 nlohmann::json reparsed = nlohmann::json::parse( serialized );
273 BOOST_CHECK( reparsed[
"net_chain_classes"].is_object() );
274 BOOST_CHECK( reparsed[
"net_chain_classes"].
empty() );
281 static_cast<nlohmann::json&
>( reparsedInternals ) = reparsed;
301 nlohmann::json reparsed = nlohmann::json::parse( source.
FormatAsString() );
304 BOOST_REQUIRE_EQUAL( reparsed[
"net_chain_classes"].size(), 1u );
307 reparsed[
"net_chain_classes"][
"EMPTY"] =
"";
312 static_cast<nlohmann::json&
>( reparsedInternals ) = reparsed;
331 BOOST_CHECK( a == b );
337 BOOST_CHECK( a != b );
341 BOOST_CHECK( a == b );
345 BOOST_CHECK( a != b );
356 std::shared_ptr<NETCLASS> replacement = std::make_shared<NETCLASS>(
NETCLASS::Default,
true );
357 replacement->SetTrackWidth( 300000 );
361 BOOST_CHECK( a != b );
373 std::shared_ptr<NETCLASS> highSpeedA = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
374 std::shared_ptr<NETCLASS> highSpeedB = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
379 BOOST_CHECK( a == b );
381 highSpeedA->SetClearance( 100000 );
383 BOOST_CHECK( a != b );
385 highSpeedB->SetClearance( 100000 );
387 BOOST_CHECK( a == b );
403 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
404 highSpeed->SetClearance( 150000 );
405 highSpeed->SetTrackWidth( 127000 );
406 std::map<wxString, std::shared_ptr<NETCLASS>> classes;
407 classes[wxS(
"HighSpeed" )] = highSpeed;
417 BOOST_CHECK( source == sink );
423 BOOST_CHECK( source != sink );
439 std::shared_ptr<NETCLASS> stale = std::make_shared<NETCLASS>( wxS(
"StaleClass" ),
false );
440 std::map<wxString, std::shared_ptr<NETCLASS>> staleClasses;
441 staleClasses[wxS(
"StaleClass" )] = stale;
449 BOOST_CHECK( source == sink );
463 std::shared_ptr<NETCLASS> stalePower = std::make_shared<NETCLASS>( wxS(
"StalePower" ),
false );
464 std::map<wxString, std::shared_ptr<NETCLASS>> staleClasses;
465 staleClasses[wxS(
"StalePower" )] = stalePower;
489 std::shared_ptr<NETCLASS> highSpeed = std::make_shared<NETCLASS>( wxS(
"HighSpeed" ),
false );
490 std::map<wxString, std::shared_ptr<NETCLASS>> classes;
491 classes[wxS(
"HighSpeed" )] = highSpeed;
void CloneFrom(const JSON_SETTINGS_INTERNALS &aOther)
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
const std::string FormatAsString()
JSON_SETTINGS_INTERNALS * Internals()
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
A collection of nets and the parameters used to route or test these nets.
static const char Default[]
the name of the default NETCLASS
void SetClearance(int aClearance)
void SetDescription(const wxString &aDesc)
void SetTrackWidth(int aWidth)
NET_SETTINGS stores various net-related settings in a project context.
void ClearChainPatternAssignments()
Clears all chain-derived pattern assignments.
void SetNetChainClass(const wxString &aChain, const wxString &aClass)
Assign a net chain to a named class (used by inNetChainClass() DRC scope).
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const wxString &aNetName)
Fetches the effective (may be aggregate) netclass for the given net name.
wxString GetNetChainClass(const wxString &aChain) const
Look up the class assigned to a chain. Empty string means "no class".
bool HasEffectiveNetClass(const wxString &aNetName) const
Determines if an effective netclass for the given net name has been cached.
void SetNetclasses(const std::map< wxString, std::shared_ptr< NETCLASS > > &netclasses)
Sets all netclass Calling this method will reset the effective netclass calculation caches.
void SetNetclassLabelAssignment(const wxString &netName, const std::set< wxString > &netclasses)
Sets a net name to netclasses assignment Calling user is responsible for resetting the effective netc...
void SetNetclassPatternAssignment(const wxString &pattern, const wxString &netclass)
Sets a netclass pattern assignment Calling this method will reset the effective netclass calculation ...
const std::map< wxString, std::shared_ptr< NETCLASS > > & GetNetclasses() const
Gets all netclasses.
std::shared_ptr< NETCLASS > GetDefaultNetclass() const
Gets the default netclass for the project.
const std::map< wxString, wxString > & GetNetChainClasses() const
void SetChainPatternAssignment(const wxString &pattern, const wxString &netclass)
Sets a chain-derived netclass pattern assignment.
void CopyFrom(NET_SETTINGS &aOther)
Deep-copy the persisted contents of aOther into this instance.
std::vector< std::pair< std::unique_ptr< EDA_COMBINED_MATCHER >, wxString > > & GetNetclassPatternAssignments()
Gets the netclass pattern assignments.
void ClearNetChainClasses()
Removes all chain-to-class assignments.
void SetNetclass(const wxString &netclassName, std::shared_ptr< NETCLASS > &netclass)
Sets the given netclass Calling user is responsible for resetting the effective netclass calculation ...
void SetDefaultNetclass(std::shared_ptr< NETCLASS > netclass)
Sets the default netclass for the project Calling user is responsible for resetting the effective net...
static bool empty(const wxTextEntryBase *aCtrl)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ChainClassAssignmentAffectsEquality)
static bool resolvesToNetclass(NET_SETTINGS &aSettings, const wxString &aNetName, const wxString &aExpected)
BOOST_CHECK_EQUAL(result, "25.4")