Skip to content

Commit 77ae15a

Browse files
authored
Merge pull request #120 from pjohnmeyer/check_by_reference
Take UnitTest::Check parameter by const reference
2 parents 510903c + de91518 commit 77ae15a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

UnitTest++/Checks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace UnitTest {
99

1010

1111
template< typename Value >
12-
bool Check(Value const value)
12+
bool Check(Value const& value)
1313
{
1414
return !!value; // doing double negative to avoid silly VS warnings
1515
}

tests/TestChecks.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,32 @@ namespace {
315315
CHECK_EQUAL(1234, reporter.lastFailedLine);
316316
}
317317

318+
class TruthyUnlessCopied
319+
{
320+
public:
321+
TruthyUnlessCopied()
322+
: truthy_(true)
323+
{
324+
}
325+
326+
TruthyUnlessCopied(const TruthyUnlessCopied&)
327+
: truthy_(false)
328+
{
329+
}
330+
331+
operator bool() const
332+
{
333+
return truthy_;
334+
}
335+
336+
private:
337+
bool truthy_;
338+
};
339+
340+
TEST(CheckProperlyDealsWithOperatorBoolOverrides)
341+
{
342+
TruthyUnlessCopied objectThatShouldBeTruthy;
343+
CHECK(objectThatShouldBeTruthy);
344+
}
345+
318346
}

0 commit comments

Comments
 (0)