'C++ BOOST Unit Tests: Invert BOOST_CHECK_EQUAL for not equal
Is there a way to check for inequality when writing Unit Tests with BOOST?
There is a macro BOOST_CHECK_EQUAL, however there does not appear to be a BOOST_CHECK_NOT_EQUAL macro.
I assume it must be possible to check for inequality in a BOOST Unit Test? I could not find anything from a duckduckgo search however.
Solution 1:[1]
The macro you're looking for is BOOST_CHECK_NE:
BOOST_CHECK_NE(a,b);
BOOST_CHECK_EQUAL(a,b);
Solution 2:[2]
Since accepting the answer I have discovered some further information:
BOOST_CHECK_NE(a, b)
does what I intended to do, however it has the side effect of requiring a/b to define a stream insertion operator<< for whatever type a/b is.
BOOST_CHECK(a != b)
doesn't require this, so I went with this option instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sehe |
| Solution 2 | FreelanceConsultant |
