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 (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 here:
18 * https://www.gnu.org/licenses/gpl-3.0.html
19 * or you may write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
30
31#include <pin_numbers.h>
32#include <wx/string.h>
33
34
36{
37public:
39 {
40 }
41};
42
43
45{
46 wxString m_lhs;
47 wxString m_rhs;
49};
50
54BOOST_FIXTURE_TEST_SUITE( SchInternalUnits, TEST_PIN_NUMBERS )
55
56
57BOOST_AUTO_TEST_CASE( ComparePinNumbers )
58{
59
60 const std::vector<TEST_PIN_NUMBER_CMP_CASE> cases = {
61 {
62 wxT( "+V" ),
63 wxT( "+V" ),
64 0,
65 },
66 {
67 wxT( "+V1234" ),
68 wxT( "+V" ),
69 2,
70 },
71 {
72 wxT( "+V" ),
73 wxT( "+V1234" ),
74 -2,
75 },
76 {
77 wxT( "Pin1" ),
78 wxT( "Pin2" ),
79 -1
80 },
81 {
82 wxT( "Pin2" ),
83 wxT( "Pin1" ),
84 1
85 },
86 {
87 wxT( "Pin1" ),
88 wxT( "Pin1" ),
89 0
90 },
91 {
92 wxT( "1Pin" ),
93 wxT( "2Pin" ),
94 -1
95 },
96 {
97 wxT( "2Pin" ),
98 wxT( "1Pin" ),
99 1
100 },
101 {
102 wxT( "1Pin" ),
103 wxT( "1Pin" ),
104 0
105 },
106 {
107 wxT( "+3V3" ),
108 wxT( "+3.3" ),
109 0
110 },
111 {
112 wxT( "+5V" ),
113 wxT( "+6V" ),
114 -1
115 },
116 {
117 wxT( "+6V" ),
118 wxT( "+5V" ),
119 1
120 }
121
122 };
123
124 for( auto& el : cases )
125 {
126 int retval = PIN_NUMBERS::Compare( el.m_lhs, el.m_rhs );
127 wxString msg;
128
129 msg.Printf( "Comparing %s and %s failed [%d != %d]", el.m_lhs, el.m_rhs, retval, el.m_return );
130 BOOST_CHECK_MESSAGE( retval == el.m_return, msg.ToStdString() );
131 }
132}
133
134BOOST_AUTO_TEST_SUITE_END()
static int Compare(const wxString &lhs, const wxString &rhs)
BOOST_AUTO_TEST_CASE(ComparePinNumbers)
Declare the test suite.