KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_component_class_settings.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 <boost/test/unit_test.hpp>
21
23
24
25BOOST_AUTO_TEST_SUITE( ComponentClassSettingsTests )
26
27
28// Guards the dirty-check path used by the project save framework. The stubbed
29// operator== previously threw, so any equality comparison crashed.
30BOOST_AUTO_TEST_CASE( DefaultsCompareEqual )
31{
32 COMPONENT_CLASS_SETTINGS a( nullptr, "" );
33 COMPONENT_CLASS_SETTINGS b( nullptr, "" );
34
35 BOOST_CHECK( a == b );
36 BOOST_CHECK( !( a != b ) );
37}
38
39
40BOOST_AUTO_TEST_CASE( SheetComponentClassFlagAffectsEquality )
41{
42 COMPONENT_CLASS_SETTINGS a( nullptr, "" );
43 COMPONENT_CLASS_SETTINGS b( nullptr, "" );
44
46
47 BOOST_CHECK( a != b );
48
50
51 BOOST_CHECK( a == b );
52}
53
54
55BOOST_AUTO_TEST_CASE( AssignmentAffectsEquality )
56{
57 COMPONENT_CLASS_SETTINGS a( nullptr, "" );
58 COMPONENT_CLASS_SETTINGS b( nullptr, "" );
59
61 assignment.SetComponentClass( wxS( "PowerNets" ) );
63 wxEmptyString );
64
65 a.AddComponentClassAssignment( assignment );
66
67 BOOST_CHECK( a != b );
68
69 b.AddComponentClassAssignment( assignment );
70
71 BOOST_CHECK( a == b );
72}
73
74
75// A single differing condition field must break equality between otherwise
76// identical assignments.
77BOOST_AUTO_TEST_CASE( AssignmentConditionDataAffectsEquality )
78{
79 COMPONENT_CLASS_SETTINGS a( nullptr, "" );
80 COMPONENT_CLASS_SETTINGS b( nullptr, "" );
81
83 assignmentA.SetComponentClass( wxS( "PowerNets" ) );
85 wxEmptyString );
86
88 assignmentB.SetComponentClass( wxS( "PowerNets" ) );
90 wxEmptyString );
91
92 a.AddComponentClassAssignment( assignmentA );
93 b.AddComponentClassAssignment( assignmentB );
94
95 BOOST_CHECK( a != b );
96}
97
98
void AddCondition(const CONDITION_TYPE aCondition, const wxString &aPrimaryData, const wxString &aSecondaryData)
Sets the given condition type with the assocated match data.
void SetComponentClass(const wxString &aComponentClass)
Sets the resulting component class for matching footprints.
COMPONENT_CLASS_SETTINGS stores data for component classes, including rules for automatic generation ...
void SetEnableSheetComponentClasses(bool aEnabled)
Sets whether component classes should be generated for components in hierarchical sheets.
void AddComponentClassAssignment(const COMPONENT_CLASS_ASSIGNMENT_DATA &aAssignment)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(DefaultsCompareEqual)
BOOST_AUTO_TEST_SUITE_END()