KiCad PCB EDA Suite
test_pin_numbers.cpp File Reference

Test suite for Pin number comparison functions. More...

#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pin_numbers.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

class  TEST_PIN_NUMBERS
 
struct  TEST_PIN_NUMBER_CMP_CASE
 

Functions

 BOOST_AUTO_TEST_CASE (ComparePinNumbers)
 Declare the test suite. More...
 

Detailed Description

Test suite for Pin number comparison functions.

Definition in file test_pin_numbers.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( ComparePinNumbers  )

Declare the test suite.

Definition at line 57 of file test_pin_numbers.cpp.

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}
static int Compare(const wxString &lhs, const wxString &rhs)

References PIN_NUMBERS::Compare().