Skip to content

Commit

Permalink
Fixed SumCopy test
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhmm committed Oct 1, 2024
1 parent 812223e commit 339be99
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions omnn/math/test/Sum_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ void ohashes(const Valuable& v)
}
}

BOOST_AUTO_TEST_CASE(SumCopy_test
, *disabled()
) {
Sum s;
s += 1;
s += 2;
s += 3;
auto s2 = s;
BOOST_TEST(s == s2);
BOOST_AUTO_TEST_CASE(SumCopy_test) {
Sum sum;
sum += 1; // Sum just became Integer (polymorphic typisation in action)
sum += 2;
sum += 3;

//auto s2 = sum; // Sum::operator= called passing Integer& instead of Sum&
Valuable s1 = sum; // Wraps morphed objects
BOOST_TEST(sum == s1);
BOOST_TEST(s1 == sum);

static_cast<Valuable*>(&sum)->~Valuable();
//^ otherwise ~Sum called on Integer object

new (&sum) omnn::math::Sum();
//^ otherwise ~Sum called twice
}

BOOST_AUTO_TEST_CASE(SumOrderComparator_test
Expand Down

0 comments on commit 339be99

Please sign in to comment.