Skip to content

Commit

Permalink
Make unit test more reliable, fix resulting failure
Browse files Browse the repository at this point in the history
This unit test was not catching a defect on Mac/Linux because of the way that the compiler can optionally optimize out write operations that occur in the destructor.  Change the test to make use of a static member instead so as to avoid this.
  • Loading branch information
codemercenary committed Oct 21, 2015
1 parent c8ed947 commit 8b22099
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/autowiring/test/AutoSignalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,21 @@ namespace {
class WiresInOuterScope {
public:
WiresInOuterScope(void) {
s_isConstructed = true;
outer(&OuterType::sig) += [this] {
ASSERT_EQ(0xDEADBEEFC0FECAFE, magic);
ASSERT_TRUE(s_isConstructed) << "Signal handler invoked on an object that was already destroyed";
};
}

~WiresInOuterScope(void) {
magic = 0xEEEE0000FFFF0000;
s_isConstructed = false;
}

Autowired<OuterType> outer;
uint64_t magic = 0xDEADBEEFC0FECAFE;
static bool s_isConstructed;
};

bool WiresInOuterScope::s_isConstructed = false;
}

TEST_F(AutoSignalTest, OuterPostDereference) {
Expand Down

0 comments on commit 8b22099

Please sign in to comment.