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
21#include <import_net_map.h>
22#include <reporter.h>
23
24BOOST_AUTO_TEST_SUITE( ImportNetMap )
25
26BOOST_AUTO_TEST_CASE( OnlyAnUnambiguousResolvedNetIsRenamedOnTheBoard )
27{
29 auto add = [&]( const wxString& generated, const wxString& target, IMPORT_NET_STATUS status )
30 {
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
52 {
53 add( wxS( "N6" ), wxS( "Net-(R6-Pad1)" ), status );
54 }
55
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
A wrapper for reporting to a wxString object.
Definition reporter.h:242
std::map< wxString, wxString > GetBoardNetNameMap(const IMPORT_NET_MAP &aMap, REPORTER &aReporter)
Reduce the map to the board net renames it justifies.
IMPORT_NET_STATUS
How completely a source net survived conversion.
@ BUS
the source net is carried by a bus
@ NO_CONNECT
the source marks the net as deliberately unconnected
@ RESOLVED
exactly one physical net carries the source net
@ SPLIT
the source net reaches more than one physical net
@ UNCONNECTED
the source net reaches no physical net
wxString generatedName
wxString originalName
wxString nameAtImport
IMPORT_NET_STATUS status
Import provenance, held only for the lifetime of the importing SCHEMATIC.
std::vector< IMPORT_NET_MAP_ENTRY > entries
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
IbisParser parser & reporter
BOOST_CHECK_EQUAL(result, "25.4")