KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_import_net_map.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 <
qa_utils/wx_utils/unit_test_utils.h
>
21
#include <
import_net_map.h
>
22
#include <
reporter.h
>
23
24
BOOST_AUTO_TEST_SUITE
( ImportNetMap )
25
26
BOOST_AUTO_TEST_CASE
( OnlyAnUnambiguousResolvedNetIsRenamedOnTheBoard )
27
{
28
IMPORT_NET_MAP
map;
29
auto
add = [&](
const
wxString& generated,
const
wxString& target,
IMPORT_NET_STATUS
status )
30
{
31
IMPORT_NET_MAP_ENTRY
entry;
32
entry.
originalName
= generated;
33
entry.
generatedName
= generated;
34
entry.
nameAtImport
= target;
35
entry.
status
= status;
36
map.
entries
.push_back( entry );
37
};
38
39
add( wxS(
"N1"
), wxS(
"Net-(R1-Pad1)"
),
IMPORT_NET_STATUS::RESOLVED
);
40
41
// One source reaching two KiCad nets: no single name to rename to.
42
add( wxS(
"N2"
), wxS(
"Net-(R2-Pad1)"
),
IMPORT_NET_STATUS::RESOLVED
);
43
add( wxS(
"N2"
), wxS(
"Net-(R3-Pad1)"
),
IMPORT_NET_STATUS::RESOLVED
);
44
45
// Two sources reaching one KiCad net: renaming both would collide, and the applier rejects a
46
// colliding batch outright, failing the whole board import.
47
add( wxS(
"N4"
), wxS(
"Net-(R4-Pad1)"
),
IMPORT_NET_STATUS::RESOLVED
);
48
add( wxS(
"N5"
), wxS(
"Net-(R4-Pad1)"
),
IMPORT_NET_STATUS::RESOLVED
);
49
50
for
(
IMPORT_NET_STATUS
status : {
IMPORT_NET_STATUS::NO_CONNECT
,
IMPORT_NET_STATUS::UNCONNECTED
,
51
IMPORT_NET_STATUS::BUS
,
IMPORT_NET_STATUS::SPLIT
} )
52
{
53
add( wxS(
"N6"
), wxS(
"Net-(R6-Pad1)"
), status );
54
}
55
56
WX_STRING_REPORTER
reporter
;
57
std::map<wxString, wxString> names =
GetBoardNetNameMap
( map,
reporter
);
58
59
BOOST_REQUIRE_EQUAL( names.size(), 1 );
60
BOOST_CHECK_EQUAL
( names.at( wxS(
"N1"
) ), wxString(
"Net-(R1-Pad1)"
) );
61
BOOST_CHECK(
reporter
.GetMessages().Contains( wxS(
"N2"
) ) );
62
BOOST_CHECK(
reporter
.GetMessages().Contains( wxS(
"Net-(R4-Pad1)"
) ) );
63
}
64
65
BOOST_AUTO_TEST_SUITE_END
()
WX_STRING_REPORTER
A wrapper for reporting to a wxString object.
Definition
reporter.h:242
GetBoardNetNameMap
std::map< wxString, wxString > GetBoardNetNameMap(const IMPORT_NET_MAP &aMap, REPORTER &aReporter)
Reduce the map to the board net renames it justifies.
Definition
import_net_map.cpp:42
import_net_map.h
IMPORT_NET_STATUS
IMPORT_NET_STATUS
How completely a source net survived conversion.
Definition
import_net_map.h:34
IMPORT_NET_STATUS::BUS
@ BUS
the source net is carried by a bus
Definition
import_net_map.h:37
IMPORT_NET_STATUS::NO_CONNECT
@ NO_CONNECT
the source marks the net as deliberately unconnected
Definition
import_net_map.h:38
IMPORT_NET_STATUS::RESOLVED
@ RESOLVED
exactly one physical net carries the source net
Definition
import_net_map.h:35
IMPORT_NET_STATUS::SPLIT
@ SPLIT
the source net reaches more than one physical net
Definition
import_net_map.h:36
IMPORT_NET_STATUS::UNCONNECTED
@ UNCONNECTED
the source net reaches no physical net
Definition
import_net_map.h:39
reporter.h
IMPORT_NET_MAP_ENTRY
Definition
import_net_map.h:55
IMPORT_NET_MAP_ENTRY::generatedName
wxString generatedName
Definition
import_net_map.h:60
IMPORT_NET_MAP_ENTRY::originalName
wxString originalName
Definition
import_net_map.h:59
IMPORT_NET_MAP_ENTRY::nameAtImport
wxString nameAtImport
Definition
import_net_map.h:61
IMPORT_NET_MAP_ENTRY::status
IMPORT_NET_STATUS status
Definition
import_net_map.h:62
IMPORT_NET_MAP
Import provenance, held only for the lifetime of the importing SCHEMATIC.
Definition
import_net_map.h:75
IMPORT_NET_MAP::entries
std::vector< IMPORT_NET_MAP_ENTRY > entries
Definition
import_net_map.h:76
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:79
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
reporter
IbisParser parser & reporter
Definition
test_kibis.cpp:619
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
eeschema
test_import_net_map.cpp
Generated on Thu Sep 17 2026 00:06:26 for KiCad PCB EDA Suite by
1.13.2