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
26
#include <
qa_utils/wx_utils/unit_test_utils.h
>
27
28
#include <
pin_numbers.h
>
29
#include <wx/string.h>
30
31
32
class
TEST_PIN_NUMBERS
33
{
34
public
:
35
TEST_PIN_NUMBERS
()
36
{
37
}
38
};
39
40
41
struct
TEST_PIN_NUMBER_CMP_CASE
42
{
43
wxString
m_lhs
;
44
wxString
m_rhs
;
45
int
m_return
;
46
};
47
51
BOOST_FIXTURE_TEST_SUITE( SchInternalUnits,
TEST_PIN_NUMBERS
)
52
53
54
BOOST_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
131
BOOST_AUTO_TEST_SUITE_END
()
PIN_NUMBERS::Compare
static int Compare(const wxString &lhs, const wxString &rhs)
Definition
pin_numbers.cpp:131
TEST_PIN_NUMBERS
Definition
test_pin_numbers.cpp:33
TEST_PIN_NUMBERS::TEST_PIN_NUMBERS
TEST_PIN_NUMBERS()
Definition
test_pin_numbers.cpp:35
pin_numbers.h
TEST_PIN_NUMBER_CMP_CASE
Definition
test_pin_numbers.cpp:42
TEST_PIN_NUMBER_CMP_CASE::m_return
int m_return
Definition
test_pin_numbers.cpp:45
TEST_PIN_NUMBER_CMP_CASE::m_rhs
wxString m_rhs
Definition
test_pin_numbers.cpp:44
TEST_PIN_NUMBER_CMP_CASE::m_lhs
wxString m_lhs
Definition
test_pin_numbers.cpp:43
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_MESSAGE
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
unit_test_utils.h
src
qa
tests
eeschema
test_pin_numbers.cpp
Generated on Fri Jun 26 2026 00:05:44 for KiCad PCB EDA Suite by
1.13.2