45 using CASE = std::pair<std::string, int>;
47 const std::vector<CASE> cases = {
48 {
"", 0 }, {
"foo", 0 },
52 {
"Foo42", 42 }, {
"12Foo42", 42 },
56 for(
const auto& c : cases )
68 using CASE = std::pair<std::pair<std::string, std::string>, std::pair<int, int>>;
70 const std::vector<CASE> cases = {
71 { {
"a",
"b" }, { -1, -1 } },
72 { {
"b",
"a" }, { 1, 1 } },
73 { {
"a",
"a" }, { 0, 0 } },
74 { {
"a",
"A" }, { 1, 0 } },
75 { {
"A",
"a" }, { -1, 0 } },
76 { {
"a",
"" }, { 1, 1 } },
77 { {
"",
"a" }, { -1, -1 } },
78 { {
"1",
"" }, { 1, 1 } },
79 { {
"",
"1" }, { -1, -1 } },
80 { {
"10",
"2" }, { 1, 1 } },
81 { {
"2",
"10" }, { -1, -1 } },
82 { {
"2",
"2" }, { 0, 0 } },
83 { {
"10",
"10" }, { 0, 0 } },
84 { {
"01",
"1" }, { 0, 0 } },
85 { {
"01a",
"1a" }, { 0, 0 } },
86 { {
"01a",
"1b" }, { -1, -1 } },
87 { {
"01b",
"1a" }, { 1, 1 } },
88 { {
"10 ten",
"2 two" }, { 1, 1 } },
89 { {
"SYM1",
"sym2" }, { -1, -1 } },
90 { {
"sym2",
"SYM1" }, { 1, 1 } },
91 { {
"a10b20c30",
"a10b20c31" }, { -1, -1 } },
92 { {
"a10b20c31",
"a10b20c30" }, { 1, 1 } },
93 { {
"10UF",
"10UF" }, { 0, 0 } },
94 { {
"10uF",
"10uF" }, { 0, 0 } },
95 { {
"u10",
"u10" }, { 0, 0 } },
96 { {
"U10",
"U10" }, { 0, 0 } },
97 { {
"u10",
"U10" }, { 1, 0 } },
98 { {
"U10",
"u10" }, { -1, 0 } },
99 { {
"U10.1",
"U10.10" }, { -1, -1 } },
100 { {
"U10-1",
"U10-10" }, { -1, -1 } },
101 { {
"U10,1",
"U10,10" }, { -1, -1 } },
102 { {
"U10.A",
"U10.a" }, { -1, 0 } },
103 { {
"U10-A",
"U10-a" }, { -1, 0 } },
104 { {
"U10,A",
"U10,a" }, { -1, 0 } },
107 for(
const auto& c : cases )
109 BOOST_CHECK_MESSAGE(
StrNumCmp( c.first.first, c.first.second ) == c.second.first,
110 c.first.first +
" AND " + c.first.second +
" failed for case sensitive" );
113 StrNumCmp( c.first.first, c.first.second,
true ) == c.second.second,
114 c.first.first +
" AND " + c.first.second +
" failed for case insensitive" );
121 using CASE = std::pair<std::pair<wxString, wxString>,
int>;
123 const std::vector<CASE> cases = {
124 { { wxT(
"100" ), wxT(
"10" ) }, 1 },
125 { { wxT(
"10K" ), wxT(
"1K" ) }, 1 },
126 { { wxT(
"10K" ), wxT(
"1K5" ) }, 1 },
127 { { wxT(
"10K" ), wxT(
"10,000" ) }, 0 },
128 { { wxT(
"1K5" ), wxT(
"1.5K" ) }, 0 },
129 { { wxT(
"1K5" ), wxT(
"1,5K" ) }, 0 },
130 { { wxT(
"K5" ), wxT(
"1K" ) }, -1 },
131 { { wxT(
"1K5" ), wxT(
"K55" ) }, 1 },
132 { { wxT(
"1R5" ), wxT(
"1.5" ) }, 0 },
133 { { wxT(
"1u5F" ), wxT(
"1.5uF" ) }, 0 },
134 { { wxT(
"1µ5" ), wxT(
"1u5" ) }, 0 },
137 for(
const auto& c : cases )
140 c.first.first +
" AND " + c.first.second +
" failed" );
150 using CASE = std::pair<double, std::string>;
153 const std::vector<CASE> cases = {
157 { 0.00001523,
"0.00001523" },
158 { 0.00000000000000001523,
"0" },
159 { 623523,
"623523" },
162 for(
const auto& c : cases )
176 using CASE = std::pair<wxString, wxString>;
178 const std::vector<CASE> cases = {
179 { wxS(
"I will display € €" ), wxS(
"I will display € €" ) },
180 { wxS(
"<" ), wxS(
"&lt;" ) },
181 { wxS(
"Don't Ω" ), wxS(
"Don't Ω" ) },
184 for(
const auto& c : cases )
186 wxString original( c.first );
203 std::vector<wxString> variantNames;
206 variantNames.emplace_back( wxS(
"Variant1" ) );
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
wxString GetDefaultVariantName()
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
int SortVariantNames(const wxString &aLhs, const wxString &aRhs)
std::string UIDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
wxString UnescapeHTML(const wxString &aString)
Return a new wxString unescaped from HTML format.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(TrailingInt)
Declare the test suite.
BOOST_CHECK_EQUAL(result, "25.4")