KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_erc_global_labels.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 3
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
22
23#include <connection_graph.h>
24#include <advanced_config.h>
25#include <scoped_set_reset.h>
26#include <schematic.h>
27#include <erc/erc_settings.h>
28#include <erc/erc.h>
29#include <erc/erc_report.h>
31#include <locale_io.h>
32
34{
37
39 std::unique_ptr<SCHEMATIC> m_schematic;
40};
41
42
44{
46 auto& enabled = const_cast<ADVANCED_CFG&>( ADVANCED_CFG::GetCfg() ).m_ConnectivityEngine;
47 SCOPED_SET_RESET restore( enabled, enabled );
48
49 // Check for Errors when using global labels
50 std::vector<std::pair<wxString, int>> tests =
51 {
52 { "issue9367", 13 }
53 };
54
55 for( bool useEngine : { false, true } )
56 {
57 enabled = useEngine;
58
59 for( const std::pair<wxString, int>& test : tests )
60 {
61 BOOST_TEST_CONTEXT( test.first.ToStdString() << " engine=" << useEngine )
62 {
63 KI_TEST::LoadSchematic( m_settingsManager, test.first, m_schematic );
64
65 ERC_SETTINGS& settings = m_schematic->ErcSettings();
66 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
67
68 // Skip the "Modified symbol" warning
71
72 // Skip the unconnected wire endpoints warning
74
75 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
76 m_schematic->ConnectionGraph()->Recalculate( sheets, true );
77 m_schematic->ConnectionGraph()->RunERC();
78
79 ERC_TESTER tester( m_schematic.get() );
82 tester.TestNoConnectPins();
83 tester.TestPinToPin();
84 tester.TestSimilarLabels();
85
87
88 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MM );
89
90 BOOST_CHECK_MESSAGE( errors.GetCount() == test.second,
91 "Expected " << test.second << " errors in " << test.first.ToStdString()
92 << " but got " << errors.GetCount() << "\n"
93 << reportWriter.GetTextReport() );
94
95
96 }
97 }
98 }
99}
100
101
103{
105
106 // Check for Errors when using global labels
107 std::vector<std::pair<wxString, int>> tests = { { "issue13212", 3 },
108 { "erc_label_test", 7 } };
109
110 for( const std::pair<wxString, int>& test : tests )
111 {
112 KI_TEST::LoadSchematic( m_settingsManager, test.first, m_schematic );
113
114 ERC_SETTINGS& settings = m_schematic->ErcSettings();
115 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
116
117 // Skip the "Modified symbol" warning
120
121 // Configure the rules under test
124
125 // Silence dangling wire errors
127
128 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
129 m_schematic->ConnectionGraph()->Recalculate( sheets, true );
130 m_schematic->ConnectionGraph()->RunERC();
131
132 ERC_TESTER tester( m_schematic.get() );
135 tester.TestNoConnectPins();
136 tester.TestPinToPin();
137 tester.TestSimilarLabels();
138
140
141 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MM );
142
143 BOOST_CHECK_MESSAGE( errors.GetCount() == test.second,
144 "Expected " << test.second << " errors in " << test.first.ToStdString()
145 << " but got " << errors.GetCount() << "\n"
146 << reportWriter.GetTextReport() );
147
148 }
149}
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format in the C-locale.
Container for ERC settings.
std::map< int, SEVERITY > m_ERCSeverities
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
Definition erc.h:60
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition erc.cpp:1709
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Definition erc.cpp:2696
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Definition erc.cpp:2145
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
Definition erc.cpp:1288
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Definition erc.cpp:923
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
RAII class that sets an value at construction and resets it to the original value at destruction.
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
int GetCount(int aSeverity=-1) const override
void SetSeverities(int aSeverities) override
@ ERCE_UNCONNECTED_WIRE_ENDPOINT
A label is connected to more than one wire.
@ ERCE_LABEL_SINGLE_PIN
A label is connected only to a single pin.
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
@ ERCE_SINGLE_GLOBAL_LABEL
A label only exists once in the schematic.
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_IGNORE
std::vector< FAB_LAYER_COLOR > dummy
std::unique_ptr< SCHEMATIC > m_schematic
BOOST_FIXTURE_TEST_CASE(ERCGlobalLabels, ERC_REGRESSION_TEST_FIXTURE)
BOOST_TEST_CONTEXT("Test Clearance")