creative formatting of chars #24

Closed
da77a opened this Issue Jun 13, 2016 · 1 comment

Projects

None yet

2 participants

@da77a
da77a commented Jun 13, 2016

I acknowledge that in many contexts people use chars to represent - well - characters. However, in many cases they are actually holding things that are not "printable" characters. And even when they are printable it is hard to know just how they should be printed.

The current behaviour is surprising (imho) - eg:

char one = 1;
char another_one = '1';
REQUIRE(one == another_one);

FAILED!
REQUIRE( one == another_one )
with expansion:
REQUIRE ( 1 == 1 )

Options seem to be

Print a 2 character expansion of "reserved" chars eg output one as '\1' and of course, '' for the dreaded \

Or concede that chars are just very short integers that may well be used to represent characters (which ones is highly dependent on locale) and "promote" them (in effect or literally) by printing them as integers. This is conventional/expected in C/C++ anyway? Far more expected than this:

PASSED!
CHECK( one+'0' == another_one )
with expansion:
CHECK( 49 == 1 )

@onqtam
Owner
onqtam commented Jun 13, 2016

it really is confusing in it's current form - I took the stringification from Catch (including this) which behaves the same way - I will rework it to just print chars as integers.

@onqtam onqtam added a commit that referenced this issue Jun 14, 2016
@onqtam fixed #24
also fixed a bug when there are no registered tests - introduced when migrating to std::set
33c75bf
@onqtam onqtam added a commit that closed this issue Sep 21, 2016
@onqtam fixed #24
also fixed a bug when there are no registered tests - introduced when migrating to std::set
2dd5528
@onqtam onqtam closed this in 2dd5528 Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment