Take UnitTest::Check parameter by const reference

Fixes #119 and #7
This commit is contained in:
Patrick Johnmeyer 2016-07-15 23:23:45 -05:00
parent 510903c880
commit 21589e5612
2 changed files with 29 additions and 1 deletions

View file

@ -9,7 +9,7 @@ namespace UnitTest {
template< typename Value >
bool Check(Value const value)
bool Check(Value const& value)
{
return !!value; // doing double negative to avoid silly VS warnings
}

View file

@ -315,4 +315,32 @@ namespace {
CHECK_EQUAL(1234, reporter.lastFailedLine);
}
TEST(CheckProperlyDealsWithOperatorBoolOverrides)
{
class TruthyUnlessCopied
{
public:
TruthyUnlessCopied()
: truthy_(true)
{
}
TruthyUnlessCopied(const TruthyUnlessCopied& orig)
: truthy_(false)
{
}
operator bool() const
{
return truthy_;
}
private:
bool truthy_;
};
TruthyUnlessCopied objectThatShouldBeTruthy;
CHECK(objectThatShouldBeTruthy);
}
}