Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit operator bool overload #916

Merged
merged 1 commit into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/gtest-1.7.0/fused-src/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19325,13 +19325,13 @@ class TestWithParam : public Test, public WithParamInterface<T> {
// AssertionResult. For more information on how to use AssertionResult with
// these macros see comments on that class.
#define EXPECT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
GTEST_TEST_BOOLEAN_((bool)(condition), #condition, false, true, \
GTEST_NONFATAL_FAILURE_)
#define EXPECT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
GTEST_NONFATAL_FAILURE_)
#define ASSERT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
GTEST_TEST_BOOLEAN_(((bool)(condition)), #condition, false, true, \
GTEST_FATAL_FAILURE_)
#define ASSERT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
Expand Down
4 changes: 4 additions & 0 deletions src/autowiring/Autowired.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class Autowired:
template<typename U>
bool operator!=(const std::shared_ptr<U>& rhs) const { return this->m_ptr != rhs; }

explicit operator bool(void) const {
return this->operator const std::shared_ptr<T>&().get() != nullptr;
}

operator T*(void) const {
return this->operator const std::shared_ptr<T>&().get();
}
Expand Down
4 changes: 2 additions & 2 deletions src/autowiring/test/AutoFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ TEST_F(AutoFilterTest, SingleImmediate) {
Decoration<pattern> dec;
packet->DecorateImmediate(dec);

ASSERT_TRUE(fgp->m_called == 1) << "Filter should called " << fgp->m_called << " times, expected 1";
ASSERT_TRUE(autowiring::get<0>(fgp->m_args).i == pattern) << "Filter argument yielded " << autowiring::get<0>(fgp->m_args).i << "expected " << pattern;
ASSERT_EQ(1, fgp->m_called) << "Filter should called " << fgp->m_called << " times, expected 1";
ASSERT_EQ(pattern, autowiring::get<0>(fgp->m_args).i) << "Filter argument yielded " << autowiring::get<0>(fgp->m_args).i << "expected " << pattern;
}
ASSERT_EQ(0, factory->GetOutstandingPacketCount()) << "Destroyed packet remains outstanding";

Expand Down