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, 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
28
29
#include <
qa_utils/wx_utils/unit_test_utils.h
>
30
31
#include <
pin_numbers.h
>
32
#include <wx/string.h>
33
34
35
class
TEST_PIN_NUMBERS
36
{
37
public
:
38
TEST_PIN_NUMBERS
()
39
{
40
}
41
};
42
43
44
struct
TEST_PIN_NUMBER_CMP_CASE
45
{
46
wxString
m_lhs
;
47
wxString
m_rhs
;
48
int
m_return
;
49
};
50
54
BOOST_FIXTURE_TEST_SUITE( SchInternalUnits,
TEST_PIN_NUMBERS
)
55
56
57
BOOST_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
134
BOOST_AUTO_TEST_SUITE_END
()
PIN_NUMBERS::Compare
static int Compare(const wxString &lhs, const wxString &rhs)
Definition
pin_numbers.cpp:135
TEST_PIN_NUMBERS
Definition
test_pin_numbers.cpp:36
TEST_PIN_NUMBERS::TEST_PIN_NUMBERS
TEST_PIN_NUMBERS()
Definition
test_pin_numbers.cpp:38
pin_numbers.h
TEST_PIN_NUMBER_CMP_CASE
Definition
test_pin_numbers.cpp:45
TEST_PIN_NUMBER_CMP_CASE::m_return
int m_return
Definition
test_pin_numbers.cpp:48
TEST_PIN_NUMBER_CMP_CASE::m_rhs
wxString m_rhs
Definition
test_pin_numbers.cpp:47
TEST_PIN_NUMBER_CMP_CASE::m_lhs
wxString m_lhs
Definition
test_pin_numbers.cpp:46
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:134
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
unit_test_utils.h
src
qa
tests
eeschema
test_pin_numbers.cpp
Generated on Sun Sep 21 2025 01:05:32 for KiCad PCB EDA Suite by
1.13.2