KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_netclass.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation; either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include <boost/test/unit_test.hpp>
21
22
#include <
netclass.h
>
23
24
25
BOOST_AUTO_TEST_SUITE
( NetclassTests )
26
27
28
BOOST_AUTO_TEST_CASE
( NameEqualsMatchesGetName )
29
{
30
// The allocation-free comparison must preserve GetName() equality for every valid name
31
auto
check = [](
const
NETCLASS
& aNetclass,
const
wxString& aName,
bool
aExpected )
32
{
33
BOOST_CHECK_EQUAL
( aNetclass.
NameEquals
( aName ), aExpected );
34
BOOST_CHECK_EQUAL
( aNetclass.
NameEquals
( aName ), aNetclass.
GetName
() == aName );
35
};
36
37
NETCLASS
first( wxS(
"Power"
) );
38
NETCLASS
second( wxS(
"Ground"
) );
39
NETCLASS
third( wxS(
"Signal"
) );
40
NETCLASS
empty
( wxEmptyString );
41
NETCLASS
comma( wxS(
"A,B"
) );
42
NETCLASS
alias( wxS(
"Alias"
) );
43
NETCLASS
composite( wxEmptyString );
44
45
check( first, wxS(
"Power"
),
true
);
46
check( first, wxS(
"Powe"
),
false
);
47
check( first, wxS(
"PowerX"
),
false
);
48
check(
empty
, wxEmptyString,
true
);
49
check(
empty
, wxS(
"Power"
),
false
);
50
51
alias.
SetConstituentNetclasses
( { &first } );
52
check( alias, wxS(
"Alias"
),
true
);
53
check( alias, wxS(
"Power"
),
false
);
54
55
composite.
SetConstituentNetclasses
( { &first, &second } );
56
check( composite, wxS(
"Power,Ground"
),
true
);
57
check( composite, wxS(
"Power;Ground"
),
false
);
58
59
composite.
SetConstituentNetclasses
( { &comma, &third } );
60
check( composite, wxS(
"A,B,Signal"
),
true
);
61
check( composite, wxS(
"A,B;Signal"
),
false
);
62
63
composite.
SetConstituentNetclasses
( { &
empty
, &first } );
64
check( composite, wxS(
",Power"
),
true
);
65
check( composite, wxS(
"Power"
),
false
);
66
}
67
68
69
BOOST_AUTO_TEST_SUITE_END
()
NETCLASS
A collection of nets and the parameters used to route or test these nets.
Definition
netclass.h:43
NETCLASS::GetName
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
Definition
netclass.cpp:368
NETCLASS::SetConstituentNetclasses
void SetConstituentNetclasses(std::vector< NETCLASS * > &&constituents)
Sets the netclasses which make up this netclass.
Definition
netclass.cpp:318
NETCLASS::NameEquals
bool NameEquals(const wxString &aName) const
Compares a name with GetName() without constructing the aggregate name.
Definition
netclass.cpp:395
empty
static bool empty(const wxTextEntryBase *aCtrl)
Definition
dialog_sim_command.cpp:37
netclass.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:80
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_netclass.cpp
Generated on Wed Oct 7 2026 00:06:07 for KiCad PCB EDA Suite by
1.13.2