47 const std::vector<INCREMENT_TEST_CASE> cases{
49 {
"", 1, 0,
"nullopt" },
50 {
"", 1, 1,
"nullopt" },
51 {
"", -1, 1,
"nullopt" },
59 {
"0", -1, 0,
"nullopt" },
61 {
"1", 1, 1,
"nullopt" },
76 {
"ABB", 1, 0,
"nullopt" },
78 {
"A-1", 1, 0,
"A-2" },
79 {
"A-1", 1, 1,
"B-1" },
81 {
"A12", 1, 0,
"A13" },
82 {
"A12", -1, 0,
"A11" },
83 {
"A12", 1, 1,
"B12" },
84 {
"A12", -1, 1,
"nullopt" },
86 {
"010", -1, 0,
"009" },
87 {
"01", 1000, 0,
"1001" },
89 {
"1", 1, std::numeric_limits<size_t>::max(),
"nullopt" },
95 for(
const auto& c : cases )
97 BOOST_TEST_INFO(
"Input: " << c.input <<
" Delta: " << c.delta <<
" Part: " << c.part );
98 wxString
result =
incrementer.Increment( c.input, c.delta, c.part ).value_or(
"nullopt" );
108 const std::vector<INCREMENT_TEST_CASE> cases{
109 { wxString(
L"1あ" ), 1, 0, wxString(
L"2あ" ) },
110 { wxString(
L"あ1" ), 1, 0, wxString(
L"あ2" ) },
111 { wxString(
L"あ1" ), 1, 1,
"nullopt" },
112 { wxString(
L"1" ), 1, 0,
"nullopt" },
113 { wxString(
L"A-1" ), 1, 0, wxString(
L"B-1" ) },
119 for(
const auto& c : cases )
121 BOOST_TEST_INFO(
"Input: " << c.input <<
" Delta: " << c.delta <<
" Part: " << c.part );
122 wxString
result =
incrementer.Increment( c.input, c.delta, c.part ).value_or(
"nullopt" );
138 const wxString alphabet =
"ABCDEFGHJKLMNPRTUVWY";
140 const std::vector<ALPHABETIC_TEST_CASE> cases{ {
141 {
"A", alphabet, 0 },
142 {
"B", alphabet, 1 },
143 {
"Y", alphabet, 19 },
144 {
"AA", alphabet, 20 },
145 {
"AY", alphabet, 39 },
148 for(
const auto& c : cases )
Heuristically increment a string's n'th part from the right.
KICOMMON_API int IndexFromAlphabetic(const wxString &aStr, const wxString &aAlphabet)
Attempt to convert a string to an integer, assuming it is an alphabetic string like "A",...
wxString KICOMMON_API AlphabeticFromIndex(size_t aN, const wxString &aAlphabet, bool aZeroBasedNonUnitCols)
Get an alphabetic string like A, B, ... Z, AA, AB, ... ZZ, AAA, ...
const wxString & alphabet
Declares a struct as the Boost test fixture.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
STRING_INCREMENTER incrementer
BOOST_AUTO_TEST_CASE(BasicCase)
Check formatting the point.
BOOST_TEST_INFO("Two-port Series .op current = "<< iDevice)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")