You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any (easy) way to attach contextual information to a REQUIRE macro?
I'd like to be able to do something like:
REQUIRE(expected_prog.size() > 0, "Program loaded from disk is empty! Either it's missing, or the file is damaged.");
Where the string "Program loaded from disk is empty! Either it's missing, or the file is damaged." is additionally printed to the output if the macro fails.
INFO()kind of does this, but the "INFO" stack is not cleared by a REQUIRE macro, so if I have a number of tests in the setup of a complex object, and the last one fails, it dumps all the INFO() messages to the console.
I can force scoping by putting each INFO()/REQUIRE() pair in a separate set of blocks, but when my setup procedure can involve 10+ calls that must be executed in sequence, it quickly gets hideous.
Before someone derails with comments about overly complex setup stuff, this is the setup procedure for a specialized piece of embedded hardware. Yes, it is that complicated, and I'm testing and exercising the low-level API. It's unavoidable.
The text was updated successfully, but these errors were encountered:
That works, but this seems like something that should be part of the core library. Python asserts work that way, though I don't know any other languages with this feature off the top of my head. C asserts don't do this, but then C asserts are a lot lower level.
Incidentally, why the do{}while(0)? Scoping with plain brackets seems to work fine.
Is there any (easy) way to attach contextual information to a REQUIRE macro?
I'd like to be able to do something like:
Where the string
"Program loaded from disk is empty! Either it's missing, or the file is damaged."
is additionally printed to the output if the macro fails.INFO()
kind of does this, but the "INFO" stack is not cleared by aREQUIRE
macro, so if I have a number of tests in the setup of a complex object, and the last one fails, it dumps all theINFO()
messages to the console.I can force scoping by putting each
INFO()/REQUIRE()
pair in a separate set of blocks, but when my setup procedure can involve 10+ calls that must be executed in sequence, it quickly gets hideous.Before someone derails with comments about overly complex setup stuff, this is the setup procedure for a specialized piece of embedded hardware. Yes, it is that complicated, and I'm testing and exercising the low-level API. It's unavoidable.
The text was updated successfully, but these errors were encountered: