Boost logo

Boost :

Subject: [boost] Proposal for a new assert macro which stores the failed values ("informative assert")
From: Viktor Sehr (viktor.sehr_at_[hidden])
Date: 2013-05-27 12:06:43


I'd like some opinions about this assert implementation which I'd like to
propose as an update of the old BOOST_ASSERT.

Basically it stores the failed values next to the expression string,
instead of just the expression string:
"INFORMATIVE_ASSERT(5*5 < 2*2);"
"5*5 < 2*2 | 25 | 4"

"INFORMATIVE_ASSERT(std::vector<int>(10).size() ==
std::vector<int>(12).size());"
"std::vector<int>(10).size() > std::vector<int>(12).size() | 10 | 12"

Notes
- If the class can't be serialized, the byte-data is logged instead.
- It writes the values to the expression string in order to be compliant
with any assert implementations

Easy to read implementation available here:
https://docs.google.com/file/d/0B69BCPzak52DcnF5dmhRRno3V2M/edit?usp=sharing

Modified version of BOOST_ASSERT available here:
https://docs.google.com/file/d/0B69BCPzak52DZW1oX1AtREM4eVU/edit?usp=sharing

/Viktor Sehr


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk