Rich Booleans

Rich Booleans
Developer(s) Q-Mentum
Stable release
2.2 / April 27, 2011 (2011-04-27)
Written in C++
Type Assertion
License wxWidgets
Website sourceforge.net/projects/rich-booleans/

Rich Booleans is a C++ library of macros that can be used in assertions to check conditions, that provide extra information when the condition fails, which helps the programmer in determining the cause of the problem. This is similar to constraints in JUnit, the main difference being that with Rich Booleans there is no clear distinction between the expected value and the checker, e.g. an assertion with a Rich Boolean for equality would be ASSERT(rbEQUAL(a,1)) while in JUnit it would be assertThat(a, eq(1)).

Rich Booleans is developed by Q-Mentum.[1]

Rich Booleans make it possible to decouple the behaviour of an assertion from the condition it checks. This means a user can write ASSERT(rbEQUAL(a,b)), whereas other frameworks would require ASSERT_EQUAL(a,b); the Rich Booleans allow to separate the functionality in the assertion and the condition, making it possible to have many variations of the assertion and the condition.

If a condition fails it will create an object of the RichBool::Analysis class, which is a base class for different types of analysis. These can be converted to text or processed further to provide the information in them to the developer or user. rbEQUAL(x,y) would create an analysis that holds the text "<x>:`1' == <y>:`2' - nok", showing the expression between < and >, and their values between ` and '. Other Rich Booleans produce longer analyses, e.g. checking string equality will show which characters match and which don't.

Starting in version 2.2 Rich Booleans uses some C++0X features, namely regular expressions and initializer lists, but still works with compilers that don't have these features.

There are over 80 different Rich Booleans.

Some frameworks that use Rich Booleans are the assertion framework ModAssert and the unit testing package UquoniTest.

See also

References

This article is issued from Wikipedia - version of the 4/20/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.