For example, say we have this class which we want to test:
struct TestMe {
vector<int> getSomething();
}
And the test function is made of:
...
vector<int> Expected;
TestMe TM;
...
Result = TM.getSomething();
BOOST_CHECK_EQUAL(Result, Expected);
...
STL vector provides a free operator==, but it does not provide an operator <<, so this code does not compile. How can I get this to work? Can i define my own operator << ? What would its implementation look like? Extra credit to the most generic solution :)
I think you should use BOOST_CHECK_EQUAL_COLLECTIONS
, this tests each element and also prints where the mismatches are:
BOOST_CHECK_EQUAL_COLLECTIONS(Result.begin(), Result.end(), Expected.begin(), Expected.end());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With