the Compartmented Robust Posix C++ Unit Test system

Chapter 12. Writing predicates

Table of Contents

Specific crpcut predicates
General predicates

There are two types of predicates; Specific crpcut predicates and General predicates.

A specific crpcut predicate is matched in ASSERT_TRUE(expr), ASSERT_FALSE(expr), VERIFY_TRUE(expr) or VERIFY_FALSE(expr) using pseudo operator =~(). The predicate is a class or struct that inherits from crpcut::predicate, has an operator()(T) and a stream insertion operator for error reporting.

A general predicate is anything that can be called as if it was a function, and that returns something that can be used as a bool. Examples of predicates are functions (of course,) pointers to functions, instances of classes that implement operator ()(). General predicates are typically used with ASSERT_PRED(pred, ...) or VERIFY_PRED(pred, ...).