KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_unique_group_name.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
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU 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
25
26
#include <boost/test/unit_test.hpp>
27
28
#include <
sch_screen.h
>
29
#include <
sch_group.h
>
30
#include <
tools/sch_tool_utils.h
>
31
32
33
namespace
34
{
35
SCH_GROUP
* addGroup(
SCH_SCREEN
& aScreen,
const
wxString& aName )
36
{
37
SCH_GROUP
*
group
=
new
SCH_GROUP
( &aScreen );
38
group
->SetName( aName );
39
aScreen.
Append
(
group
);
40
return
group
;
41
}
42
}
// namespace
43
44
45
BOOST_AUTO_TEST_SUITE
( UniqueGroupNames )
46
47
48
BOOST_AUTO_TEST_CASE
( NullScreenReturnsBase )
49
{
50
BOOST_CHECK_EQUAL
(
UniqueGroupName
(
nullptr
, wxT(
"Amp"
) ), wxString( wxT(
"Amp"
) ) );
51
}
52
53
54
BOOST_AUTO_TEST_CASE
( FreeNameIsKept )
55
{
56
SCH_SCREEN
screen;
57
addGroup( screen, wxT(
"Other Group"
) );
58
59
BOOST_CHECK_EQUAL
(
UniqueGroupName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp"
) ) );
60
}
61
62
63
BOOST_AUTO_TEST_CASE
( CollisionGetsSuffix )
64
{
65
SCH_SCREEN
screen;
66
addGroup( screen, wxT(
"Amp"
) );
67
68
BOOST_CHECK_EQUAL
(
UniqueGroupName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp1"
) ) );
69
}
70
71
72
BOOST_AUTO_TEST_CASE
( SuffixSkipsTakenNumbers )
73
{
74
SCH_SCREEN
screen;
75
addGroup( screen, wxT(
"Amp"
) );
76
addGroup( screen, wxT(
"Amp1"
) );
77
78
BOOST_CHECK_EQUAL
(
UniqueGroupName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp2"
) ) );
79
}
80
81
82
BOOST_AUTO_TEST_SUITE_END
()
BITMAPS::group
@ group
Definition
bitmaps_list.h:246
SCH_GROUP
A set of SCH_ITEMs (i.e., without duplicates).
Definition
sch_group.h:48
SCH_SCREEN
Definition
sch_screen.h:97
SCH_SCREEN::Append
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition
sch_screen.cpp:160
sch_group.h
Class to handle a set of SCH_ITEMs.
sch_screen.h
UniqueGroupName
wxString UniqueGroupName(SCH_SCREEN *aScreen, const wxString &aBaseName)
Return aBaseName, or aBaseName + smallest free integer if a group with that name already exists on aS...
Definition
sch_tool_utils.cpp:464
sch_tool_utils.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:72
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")
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(NullScreenReturnsBase)
Definition
test_unique_group_name.cpp:48
src
qa
tests
eeschema
test_unique_group_name.cpp
Generated on Fri Jul 31 2026 00:08:05 for KiCad PCB EDA Suite by
1.13.2