Test suite for general string functions.
More...
Go to the source code of this file.
Test suite for general string functions.
Definition in file test_kicad_string.cpp.
◆ BOOST_AUTO_TEST_CASE() [1/2]
BOOST_AUTO_TEST_CASE |
( |
TrailingInt |
| ) |
|
Declare the test suite.
Test the GetTrailingInt method.
Definition at line 42 of file test_kicad_string.cpp.
44 using CASE = std::pair<std::string, int>;
46 const std::vector<CASE> cases = {
47 {
"", 0 }, {
"foo", 0 },
51 {
"Foo42", 42 }, {
"12Foo42", 42 },
55 for(
const auto& c : cases )
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
References GetTrailingInt().
◆ BOOST_AUTO_TEST_CASE() [2/2]
BOOST_AUTO_TEST_CASE |
( |
NaturalNumberCompare |
| ) |
|
Test the StrNumCmp method.
Definition at line 64 of file test_kicad_string.cpp.
66 using CASE = std::pair<std::pair<std::string, std::string>, std::pair<int, int>>;
68 const std::vector<CASE> cases = {
69 { {
"a",
"b" }, { -1, -1 } },
70 { {
"b",
"a" }, { 1, 1 } },
71 { {
"a",
"a" }, { 0, 0 } },
72 { {
"a",
"A" }, { 1, 0 } },
73 { {
"A",
"a" }, { -1, 0 } },
74 { {
"a",
"" }, { 1, 1 } },
75 { {
"",
"a" }, { -1, -1 } },
76 { {
"1",
"" }, { 1, 1 } },
77 { {
"",
"1" }, { -1, -1 } },
78 { {
"10",
"2" }, { 1, 1 } },
79 { {
"2",
"10" }, { -1, -1 } },
80 { {
"2",
"2" }, { 0, 0 } },
81 { {
"10",
"10" }, { 0, 0 } },
82 { {
"01",
"1" }, { 0, 0 } },
83 { {
"01a",
"1a" }, { 0, 0 } },
84 { {
"01a",
"1b" }, { -1, -1 } },
85 { {
"01b",
"1a" }, { 1, 1 } },
86 { {
"10 ten",
"2 two" }, { 1, 1 } },
87 { {
"SYM1",
"sym2" }, { -1, -1 } },
88 { {
"sym2",
"SYM1" }, { 1, 1 } },
89 { {
"a10b20c30",
"a10b20c31" }, { -1, -1 } },
90 { {
"a10b20c31",
"a10b20c30" }, { 1, 1 } },
91 { {
"10UF",
"10UF" }, { 0, 0 } },
92 { {
"10uF",
"10uF" }, { 0, 0 } },
93 { {
"u10",
"u10" }, { 0, 0 } },
94 { {
"U10",
"U10" }, { 0, 0 } },
95 { {
"u10",
"U10" }, { 1, 0 } },
96 { {
"U10",
"u10" }, { -1, 0 } },
97 { {
"U10.1",
"U10.10" }, { -1, -1 } },
98 { {
"U10-1",
"U10-10" }, { -1, -1 } },
99 { {
"U10,1",
"U10,10" }, { -1, -1 } },
100 { {
"U10.A",
"U10.a" }, { -1, 0 } },
101 { {
"U10-A",
"U10-a" }, { -1, 0 } },
102 { {
"U10,A",
"U10,a" }, { -1, 0 } },
105 for(
const auto& c : cases )
107 BOOST_CHECK_MESSAGE(
StrNumCmp( c.first.first, c.first.second ) == c.second.first,
108 c.first.first +
" AND " + c.first.second +
" failed for case sensitive" );
111 StrNumCmp( c.first.first, c.first.second,
true ) == c.second.second,
112 c.first.first +
" AND " + c.first.second +
" failed for case insensitive" );
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
References StrNumCmp().