27#include <boost/test/data/test_case.hpp>
48 std::map<wxString, wxString>
override;
66 {
"A=B+C",
"A=B+C", {} },
67 {
"A\nB",
"A\nB", {} },
68 {
"A\tB",
"A\tB", {} },
69 {
"This is a long text with spaces",
"This is a long text with spaces", {} },
80 {
"${A}",
"${A}", {} },
83 {
"=A",
"${C}", { {
"A",
"C" } } },
84 {
"=A_B",
"${A_B}", {} },
86 {
"=A+B",
"${A}${B}", {} },
87 {
"=A+B",
"${A}${B}", {} },
88 {
"=A+B",
"${C}${B}", { {
"A",
"C" } } },
89 {
"=A+B",
"${C}${D}", { {
"A",
"C" }, {
"B",
"D" } } },
91 {
"=A",
"${C}", { {
"A",
"C" } } },
92 {
"=a",
"${C}", { {
"A",
"C" } } },
93 {
"=AB",
"${C}", { {
"AB",
"C" } } },
94 {
"=aB",
"${C}", { {
"AB",
"C" } } },
95 {
"=Ab",
"${C}", { {
"AB",
"C" } } },
96 {
"=ab",
"${C}", { {
"AB",
"C" } } },
99 {
"='This is a long text with spaces'",
"This is a long text with spaces", {} },
105 {
"='${A}'",
"${A}", {} },
106 {
"='A'+'B'",
"AB", {} },
107 {
"='A'+' '",
"A ", {} },
108 {
"=' '+'B'",
" B", {} },
109 {
"='A'+B",
"A${B}", {} },
110 {
"='A'+\"B\"",
"A${B}", {} },
111 {
"='A' + \"B\"",
"A${B}", {} },
112 {
"=\"A\"+'B'",
"${A}B", {} },
113 {
"=\"A\" + 'B'",
"${A}B", {} },
114 {
"=A+'B'",
"${A}B", {} },
115 {
"=A+' '+B",
"${A} ${B}", {} },
116 {
"='A'+B+'C'+D",
"A${B}C${D}", {} },
121 {
"=B+",
"${B}", {} },
122 {
"=+B",
"${B}", {} },
123 {
"=B++",
"${B}", {} },
124 {
"=+B+",
"${B}", {} },
125 {
"=++B",
"${B}", {} },
128 {
"= A",
"${A}", {} },
129 {
"=A ",
"${A}", {} },
130 {
"='A'B",
"A", {} },
131 {
"=A'B'",
"B", {} },
133 {
"=A+ 'B'",
"${A}B", {} },
161 {
"A=B",
"A=B", {} },
162 {
"A=B+C",
"A=B+C", {} },
163 {
"A\nB",
"A\nB", {} },
164 {
"A\tB",
"A\tB", {} },
165 {
"This is a long text with spaces",
"This is a long text with spaces", {} },
169 {
"'A'",
"'A'", {} },
173 {
"${A}",
"${A}", {} },
175 {
".A",
"${A}", {} },
176 {
".A",
"${C}", { {
"A",
"C" } } },
177 {
".A_B",
"${A_B}", {} },
179 {
"'.A'",
"${A}", {} },
180 {
"'.A''.B'",
"${A}${B}", {} },
181 {
"'.A''.B'",
"${C}${B}", { {
"A",
"C" } } },
182 {
"'.A''.B'",
"${CC}${D}", { {
"A",
"CC" }, {
"B",
"D" } } },
183 {
"A='.A', B='.B'",
"A=${A}, B=${B}", {} },
185 {
".A",
"${C}", { {
"A",
"C" } } },
186 {
".a",
"${C}", { {
"A",
"C" } } },
187 {
".AB",
"${C}", { {
"AB",
"C" } } },
188 {
".aB",
"${C}", { {
"AB",
"C" } } },
189 {
".Ab",
"${C}", { {
"AB",
"C" } } },
190 {
".ab",
"${C}", { {
"AB",
"C" } } },
194 {
". ",
"${ }", {} },
195 {
". A",
"${ A}", {} },
196 {
".A ",
"${A }", {} },
197 {
" .A",
" .A", {} },
198 {
"...",
"${..}", {} },
223 return strm <<
"[" << data.
input <<
" -> " << data.
expected <<
"]";
230 { wxT(
"" ), wxT(
"" ) },
231 { wxT(
"1" ), wxT(
"1" ) },
232 { wxT(
"A1" ), wxT(
"A1" ) },
233 { wxT(
"GND" ), wxT(
"GND" ) },
234 { wxT(
" 1 " ), wxT(
"1" ) },
235 { wxT(
" A1 " ), wxT(
"A1" ) },
238 { wxT(
"1,2" ), wxT(
"[1,2]" ) },
239 { wxT(
"1,2,3" ), wxT(
"[1,2,3]" ) },
240 { wxT(
"A1,A2,A3" ), wxT(
"[A1,A2,A3]" ) },
243 { wxT(
"1, 2, 3" ), wxT(
"[1,2,3]" ) },
244 { wxT(
" 1 , 2 , 3 " ), wxT(
"[1,2,3]" ) },
247 { wxT(
"1,2," ), wxT(
"[1,2]" ) },
248 { wxT(
"1,,2" ), wxT(
"[1,2]" ) },
251 { wxT(
"1," ), wxT(
"1" ) },
252 { wxT(
"," ), wxT(
"," ) },
268 bool outOfRange =
true;
271 BOOST_CHECK( !outOfRange );
274 BOOST_CHECK( !outOfRange );
279 BOOST_CHECK( outOfRange );
280 BOOST_CHECK_LT( clamped, -2000000000 );
284 BOOST_CHECK( outOfRange );
293 const std::map<wxString, wxString> props = {
294 { wxT(
"SANE" ), wxT(
"1000mil" ) },
295 { wxT(
"HUGE" ), wxT(
"-111339.9634mil" ) },
296 { wxT(
"JUNK" ), wxT(
"not a number" ) },
299 bool outOfRange =
true;
304 BOOST_CHECK( !outOfRange );
307 BOOST_CHECK( outOfRange );
313 BOOST_CHECK( !outOfRange );
318 BOOST_CHECK( !outOfRange );
wxString AltiumPinDesignatorToKiCad(const wxString &aDesignator)
Convert an Altium pin designator string to the equivalent KiCad pin number.
wxString AltiumSchSpecialStringsToKiCadVariables(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
wxString AltiumPcbSpecialStringsToKiCadStrings(const wxString &aString, const std::map< wxString, wxString > &aOverrides)
static int32_t ConvertToKicadUnit(const double aValue, bool *aOutOfRange=nullptr)
Convert a value in Altium's internal unit (0.1 uinch) to KiCad IU, clamped to the representable range...
static int32_t ReadKicadUnit(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault, bool *aOutOfRange=nullptr)
ALTIUM_PARSER_UTILS_FIXTURE()
Declares the struct as the Boost test fixture.
static const std::vector< PIN_DESIGNATOR_CASE > pin_designator_cases
BOOST_AUTO_TEST_CASE(ConvertToKicadUnitFlagsClampedValues)
BOOST_DATA_TEST_CASE(AltiumSchSpecialStringsToKiCadVariablesProperties, boost::unit_test::data::make(sch_special_string_to_kicad_property), data)
Test conversation from Altium Schematic Special String to a KiCad String with variables.
static const std::vector< SPECIAL_STRINGS_TO_KICAD > sch_special_string_to_kicad_property
A list of valid test strings and the expected results.
std::ostream & operator<<(std::ostream &strm, SPECIAL_STRINGS_TO_KICAD const &data)
static const std::vector< SPECIAL_STRINGS_TO_KICAD > pcb_special_string_to_kicad_property
A list of valid test strings and the expected results.
BOOST_AUTO_TEST_SUITE_END()
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")