Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creative formatting of chars #24

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

creative formatting of chars #24

da77a opened this issue Jun 13, 2016 · 1 comment

Comments

@da77a
Copy link

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
Copy link
Member

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 added a commit that referenced this issue Jun 14, 2016
also fixed a bug when there are no registered tests - introduced when migrating to std::set
@onqtam onqtam closed this as completed in 2dd5528 Sep 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants