Skip to content

Commit

Permalink
Output wrong InstanceCounter value on error to better diagnose errors…
Browse files Browse the repository at this point in the history
… in the test. Clang-win seems to produce correct code in more cases when adding those outputs (compiler bug?).
  • Loading branch information
igaztanaga committed Jan 6, 2024
1 parent 0191a31 commit f91e0e7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/allocexcept_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ int main ()
BOOST_TRY{
//Fill vector until there is no more memory
MyVect myvec(myallocator);
std::size_t i;
for(i = 0; true; ++i){
myvec.push_back(InstanceCounter());
while(true){
InstanceCounter a;
myvec.push_back(a);
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){
if(InstanceCounter::counter != 0)
if (InstanceCounter::counter != 0) {
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
} BOOST_CATCH_END

//We'll provoke an exception, let's see if exception handling works
Expand All @@ -76,12 +78,16 @@ int main ()
}
}
BOOST_CATCH(boost::interprocess::bad_alloc &){
if(InstanceCounter::counter != 0)
if(InstanceCounter::counter != 0){
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
}
BOOST_CATCH(std::length_error &){
if(InstanceCounter::counter != 0)
if(InstanceCounter::counter != 0){
std::cout << "Error: InstanceCounter::counter: " << InstanceCounter::counter;
return 1;
}
} BOOST_CATCH_END
}
BOOST_CATCH(...){
Expand Down

0 comments on commit f91e0e7

Please sign in to comment.