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 (C) 2022 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, you may find one at
18 * http://www.gnu.org/licenses/
19 */
20
23
24#include <connection_graph.h>
25#include <schematic.h>
26#include <erc/erc_settings.h>
27#include <erc/erc.h>
28#include <erc/erc_report.h>
30#include <locale_io.h>
31
33{
35 m_settingsManager( true /* headless */ )
36 { }
37
39 std::unique_ptr<SCHEMATIC> m_schematic;
40};
41
42
44{
46
47 // Check for Errors when using global labels
48 std::vector<std::pair<wxString, int>> tests =
49 {
50 { "issue9367", 12 }
51 };
52
53 for( const std::pair<wxString, int>& test : tests )
54 {
55 KI_TEST::LoadSchematic( m_settingsManager, test.first, m_schematic );
56
57 ERC_SETTINGS& settings = m_schematic->ErcSettings();
58 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
59
60 // Skip the "Modified symbol" warning
63
64 // Skip the unconnected wire endpoints warning
66
67 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
68 m_schematic->ConnectionGraph()->Recalculate( sheets, true );
69 m_schematic->ConnectionGraph()->RunERC();
70
71 ERC_TESTER tester( m_schematic.get() );
75 tester.TestNoConnectPins();
76 tester.TestPinToPin();
77 tester.TestSimilarLabels();
78
80
81 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MILLIMETRES );
82
83 BOOST_CHECK_MESSAGE( errors.GetCount() == test.second,
84 "Expected " << test.second << " errors in " << test.first.ToStdString()
85 << " but got " << errors.GetCount() << "\n"
86 << reportWriter.GetTextReport() );
87
88 }
89}
90
91
93{
95
96 // Check for Errors when using global labels
97 std::vector<std::pair<wxString, int>> tests = { { "issue13212", 3 } };
98
99 for( const std::pair<wxString, int>& test : tests )
100 {
101 KI_TEST::LoadSchematic( m_settingsManager, test.first, m_schematic );
102
103 ERC_SETTINGS& settings = m_schematic->ErcSettings();
104 SHEETLIST_ERC_ITEMS_PROVIDER errors( m_schematic.get() );
105
106 // Skip the "Modified symbol" warning
109
110 // Configure the rules under test
113
114 SCH_SHEET_LIST sheets = m_schematic->BuildSheetListSortedByPageNumbers();
115 m_schematic->ConnectionGraph()->Recalculate( sheets, true );
116 m_schematic->ConnectionGraph()->RunERC();
117
118 ERC_TESTER tester( m_schematic.get() );
122 tester.TestNoConnectPins();
123 tester.TestPinToPin();
124 tester.TestSimilarLabels();
125
127
128 ERC_REPORT reportWriter( m_schematic.get(), EDA_UNITS::MILLIMETRES );
129
130 BOOST_CHECK_MESSAGE( errors.GetCount() == test.second,
131 "Expected " << test.second << " errors in " << test.first.ToStdString()
132 << " but got " << errors.GetCount() << "\n"
133 << reportWriter.GetTextReport() );
134
135 }
136}
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format.
Definition: erc_report.cpp:44
Container for ERC settings.
Definition: erc_settings.h:129
std::map< int, SEVERITY > m_ERCSeverities
Definition: erc_settings.h:188
Definition: erc.h:52
int TestPinToPin()
Checks the full netlist against the pin-to-pin connectivity requirements.
Definition: erc.cpp:882
int TestSimilarLabels()
Checks for labels that differ only in capitalization.
Definition: erc.cpp:1140
int TestMultUnitPinConflicts()
Checks if shared pins on multi-unit symbols have been connected to different nets.
Definition: erc.cpp:1028
int TestConflictingBusAliases()
Check that there are no conflicting bus alias definitions in the schematic.
Definition: erc.cpp:410
int TestNoConnectPins()
In KiCad 5 and earlier, you could connect stuff up to pins with NC electrical type.
Definition: erc.cpp:813
int TestMultiunitFootprints()
Test if all units of each multiunit symbol have the same footprint assigned.
Definition: erc.cpp:455
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contra...
Definition: erc_settings.h:207
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.
Definition: erc_settings.h:90
@ ERCE_GLOBLABEL
A global label is unique.
Definition: erc_settings.h:74
@ ERCE_LIB_SYMBOL_MISMATCH
Symbol doesn't match copy in library.
Definition: erc_settings.h:80
@ ERCE_LIB_SYMBOL_ISSUES
Symbol not found in active libraries.
Definition: erc_settings.h:79
@ ERCE_SINGLE_GLOBAL_LABEL
A global label only exists once in the schematic.
Definition: erc_settings.h:54
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)