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

Add custom failure messages with lazy stringification #23

Closed
netheril96 opened this issue Jun 8, 2016 · 2 comments
Closed

Add custom failure messages with lazy stringification #23

netheril96 opened this issue Jun 8, 2016 · 2 comments

Comments

@netheril96
Copy link

Is it or will it possible to output custom messages only when REQUIRE or CHECK fails? In Catch, we can capture certain variables before doing the check, but that unnecessarily creates a string and then discards it when the test succeeds (which should be more common than failures).

@onqtam
Copy link
Member

onqtam commented Jun 8, 2016

this is planned - it is in the roadmap - INFO - but It will go into version 2.0 for which I cannot promise a release date. I will have to figure out the reporters API and such contextual information will have to fit the big picture. I'm gearing up for a 1.1 release with fixes in the upcoming days.

Currently I don't see how to implement this without always constructing the strings - even when the assertions pass.

@onqtam onqtam modified the milestone: doctest 2.0 Jun 8, 2016
@onqtam onqtam added the for 2.0 label Jun 8, 2016
@onqtam onqtam removed this from the doctest 2.0 milestone Jun 8, 2016
@onqtam onqtam removed the for 2.0 label Mar 15, 2017
@onqtam onqtam changed the title Custom failure messages Add custom failure messages Mar 22, 2017
@onqtam onqtam changed the title Add custom failure messages Add custom failure messages with lazy stringification Mar 23, 2017
onqtam added a commit that referenced this issue Mar 26, 2017
…d construct a message which gets printed only when an assert in the same scope (or in a nested one) after them fails. They use lazy stringification and the stack to avoid heap allocations and unnecessary string construction for the common case where no asserts fail. fixes #48 fixes #23
@onqtam
Copy link
Member

onqtam commented Mar 26, 2017

This is implemented in the dev branch - check out the documentation

onqtam added a commit that referenced this issue Mar 26, 2017
…:ostream - trying to fix builds for VS 2008/2010/2012/2013 - oddly enough 2015/2017 pass (also all gcc/clang versions under linux/osx pass as well...) - relates #23 relates #48
onqtam added a commit that referenced this issue Mar 28, 2017
onqtam added a commit that referenced this issue Mar 28, 2017
…mporaries even in C++98 (but compilation error messages will be horrible) - relates #23 relates #48
onqtam added a commit that referenced this issue Mar 28, 2017
onqtam added a commit that referenced this issue Mar 28, 2017
…- relates #23 relates #48

Basically these are just a paired INFO() with an ASSERT() inside of a code block - { INFO(msg); CHECK(expr); }
onqtam added a commit that referenced this issue Apr 10, 2017
… from an exception - relates #48 #23 (also see this Catch PR: catchorg/Catch2#876 )
onqtam added a commit that referenced this issue May 7, 2017
onqtam added a commit that referenced this issue May 7, 2017
…y const ref and use a static assert - relates #23

Added option to show duration of test case execution and added a timeout(seconds) decorator - marking them as failed if they exceed it - closes #68 - closes #67
@onqtam onqtam closed this as completed in a369a98 May 15, 2017
onqtam added a commit that referenced this issue May 15, 2017
…:ostream - trying to fix builds for VS 2008/2010/2012/2013 - oddly enough 2015/2017 pass (also all gcc/clang versions under linux/osx pass as well...) - relates #23 relates #48
onqtam added a commit that referenced this issue May 15, 2017
onqtam added a commit that referenced this issue May 15, 2017
…mporaries even in C++98 (but compilation error messages will be horrible) - relates #23 relates #48
onqtam added a commit that referenced this issue May 15, 2017
onqtam added a commit that referenced this issue May 15, 2017
…- relates #23 relates #48

Basically these are just a paired INFO() with an ASSERT() inside of a code block - { INFO(msg); CHECK(expr); }
onqtam added a commit that referenced this issue May 15, 2017
… from an exception - relates #48 #23 (also see this Catch PR: catchorg/Catch2#876 )
onqtam added a commit that referenced this issue May 15, 2017
onqtam added a commit that referenced this issue May 15, 2017
…y const ref and use a static assert - relates #23

Added option to show duration of test case execution and added a timeout(seconds) decorator - marking them as failed if they exceed it - closes #68 - closes #67
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