KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_unique_sheet_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_sheet.h
>
30
#include <
tools/sch_tool_utils.h
>
31
32
33
namespace
34
{
35
SCH_SHEET
* addSheet(
SCH_SCREEN
& aScreen,
const
wxString& aName )
36
{
37
SCH_SHEET
* sheet =
new
SCH_SHEET
();
38
sheet->
SetName
( aName );
39
aScreen.
Append
( sheet );
40
return
sheet;
41
}
42
}
// namespace
43
44
45
BOOST_AUTO_TEST_SUITE
( UniqueSheetNames )
46
47
48
BOOST_AUTO_TEST_CASE
( NullScreenReturnsBase )
49
{
50
BOOST_CHECK_EQUAL
(
UniqueSheetName
(
nullptr
, wxT(
"Amp"
) ), wxString( wxT(
"Amp"
) ) );
51
}
52
53
54
BOOST_AUTO_TEST_CASE
( FreeNameIsKept )
55
{
56
SCH_SCREEN
screen;
57
addSheet( screen, wxT(
"Other Sheet"
) );
58
59
BOOST_CHECK_EQUAL
(
UniqueSheetName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp"
) ) );
60
}
61
62
63
BOOST_AUTO_TEST_CASE
( CollisionGetsSuffix )
64
{
65
SCH_SCREEN
screen;
66
addSheet( screen, wxT(
"Amp"
) );
67
68
BOOST_CHECK_EQUAL
(
UniqueSheetName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp1"
) ) );
69
}
70
71
72
BOOST_AUTO_TEST_CASE
( SuffixSkipsTakenNumbers )
73
{
74
SCH_SCREEN
screen;
75
addSheet( screen, wxT(
"Amp"
) );
76
addSheet( screen, wxT(
"Amp1"
) );
77
addSheet( screen, wxT(
"Amp2"
) );
78
79
BOOST_CHECK_EQUAL
(
UniqueSheetName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp3"
) ) );
80
}
81
82
83
BOOST_AUTO_TEST_CASE
( ComparisonIsCaseInsensitive )
84
{
85
SCH_SCREEN
screen;
86
addSheet( screen, wxT(
"AMP"
) );
87
addSheet( screen, wxT(
"amp1"
) );
88
89
BOOST_CHECK_EQUAL
(
UniqueSheetName
( &screen, wxT(
"Amp"
) ), wxString( wxT(
"Amp2"
) ) );
90
}
91
92
93
BOOST_AUTO_TEST_SUITE_END
()
SCH_SCREEN
Definition
sch_screen.h:97
SCH_SCREEN::Append
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition
sch_screen.cpp:160
SCH_SHEET
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition
sch_sheet.h:44
SCH_SHEET::SetName
void SetName(const wxString &aName)
Definition
sch_sheet.h:137
sch_screen.h
sch_sheet.h
UniqueSheetName
wxString UniqueSheetName(SCH_SCREEN *aScreen, const wxString &aBaseName)
Return aBaseName, or aBaseName + smallest free integer if a sheet with that name already exists on aS...
Definition
sch_tool_utils.cpp:439
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_sheet_name.cpp:48
src
qa
tests
eeschema
test_unique_sheet_name.cpp
Generated on Fri Jul 31 2026 00:08:05 for KiCad PCB EDA Suite by
1.13.2