KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pin_numbers.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
25
27
28#include <pin_numbers.h>
29#include <wx/string.h>
30
31
33{
34public:
36 {
37 }
38};
39
40
42{
43 wxString m_lhs;
44 wxString m_rhs;
46};
47
51BOOST_FIXTURE_TEST_SUITE( SchInternalUnits, TEST_PIN_NUMBERS )
52
53
54BOOST_AUTO_TEST_CASE( ComparePinNumbers )
55{
56
57 const std::vector<TEST_PIN_NUMBER_CMP_CASE> cases = {
58 {
59 wxT( "+V" ),
60 wxT( "+V" ),
61 0,
62 },
63 {
64 wxT( "+V1234" ),
65 wxT( "+V" ),
66 2,
67 },
68 {
69 wxT( "+V" ),
70 wxT( "+V1234" ),
71 -2,
72 },
73 {
74 wxT( "Pin1" ),
75 wxT( "Pin2" ),
76 -1
77 },
78 {
79 wxT( "Pin2" ),
80 wxT( "Pin1" ),
81 1
82 },
83 {
84 wxT( "Pin1" ),
85 wxT( "Pin1" ),
86 0
87 },
88 {
89 wxT( "1Pin" ),
90 wxT( "2Pin" ),
91 -1
92 },
93 {
94 wxT( "2Pin" ),
95 wxT( "1Pin" ),
96 1
97 },
98 {
99 wxT( "1Pin" ),
100 wxT( "1Pin" ),
101 0
102 },
103 {
104 wxT( "+3V3" ),
105 wxT( "+3.3" ),
106 0
107 },
108 {
109 wxT( "+5V" ),
110 wxT( "+6V" ),
111 -1
112 },
113 {
114 wxT( "+6V" ),
115 wxT( "+5V" ),
116 1
117 }
118
119 };
120
121 for( auto& el : cases )
122 {
123 int retval = PIN_NUMBERS::Compare( el.m_lhs, el.m_rhs );
124 wxString msg;
125
126 msg.Printf( "Comparing %s and %s failed [%d != %d]", el.m_lhs, el.m_rhs, retval, el.m_return );
127 BOOST_CHECK_MESSAGE( retval == el.m_return, msg.ToStdString() );
128 }
129}
130
static int Compare(const wxString &lhs, const wxString &rhs)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")