//test_set is a string containing everything after "failed: " to the first "-"
//expected is a boolean value.
out << std::setfill('-') << std::setw(80) << std::left << test_set << "expected: " << expected << '\n';
Produces:
Test #15 failed: {}}------------------------------------------------------------expected: 0
Test #18 failed: {}}}}----------------------------------------------------------expected: 0
Test #32 failed: {1,2,3}a-------------------------------------------------------expected: 0
Test #33 failed: {{1,2},{3,a},{5,6},{b,c}}}a------------------------------------expected: 0
Test #35 failed: {1,2,3} a-----------------------------------------------------expected: 0
Test #36 failed: {1,2,3}{-------------------------------------------------------expected: 0
Test run complete.
Hopefully the error is clear. I have no idea why it happens or how I can fix it. Can anyone help?
Well, for one thing the number of character positions occupied by a tab character is not defined by the program, but is dependent on the display device. Another, its exact behaviour will depend on how many characters already appear on the line, before the tab.
and how do I fix it?
Ideally, find the code which puts the tab there and change it to use one or more spaces instead. If that's not possible, then you could modify the string test_set before outputting it
This mini-program is meant to take input and produce output on whether the input can be considered a mathematical set as defined by:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Set:
"{" Sequence "}"
Sequence:
<Empty>
List
List:
Element
Element "," List
Element:
Alpha-numeral
Set
What you see here is the output to my test set (taken from a text file) after intentionally creating a bug in the program (to test out my test harness). The bug you see in this case is caused when extraneous input is left over after a complete set has been read. In this case, extraneous input should not be accepted and should fail the test. However, extraneous white space is acceptable. In order to be thorough, I added test cases where extra input was placed immediately after the set in some cases and after a padding of white space in other cases.
TLDR; The tab character is intentional for testing purposes.