Skip to content

Commit

Permalink
fix leaks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ricrogz committed Jan 27, 2023
1 parent facff4f commit 04e0cf6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sketcherMinimizerMolecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ sketcherMinimizerMolecule::sketcherMinimizerMolecule()

sketcherMinimizerMolecule::~sketcherMinimizerMolecule()
{
for (auto ring : _rings) {
for (auto& ring : _rings) {
delete ring;
ring = nullptr;
}
}

Expand Down
16 changes: 16 additions & 0 deletions test/test_coordgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "maeparser/MaeConstants.hpp"
#include "maeparser/Reader.hpp"

// The sketcherMinimizerFragment class is not exposed in the library
#include "../sketcherMinimizerFragment.cpp"

using std::unordered_set;
using namespace schrodinger;

Expand Down Expand Up @@ -498,6 +501,15 @@ BOOST_AUTO_TEST_CASE(testClockwiseOrderedNaN)
sketcherMinimizerAtom* neigh1 = atoms.at(1);
neigh1->coordinates = sketcherMinimizerPointF(std::nanf("name"), std::nanf("name"));
const auto orderedNeighbors = center->clockwiseOrderedNeighbors();

// We usually allow the sketcher minimizer to clean up bonds & atoms,
// but we don't have a minimizer here
for (auto& bond : mol->getBonds()) {
delete bond;
}
for (auto& atom : atoms) {
delete atom;
}
}


Expand Down Expand Up @@ -639,4 +651,8 @@ BOOST_AUTO_TEST_CASE(testCoordgenFragmenter)
// Fragment containing atoms (9, 10)
BOOST_TEST(atoms[8]->fragment->constrained == false);
BOOST_TEST(atoms[8]->fragment->constrainedFlip == false);

for (auto& fragment : mol->_fragments) {
delete fragment;
}
}

0 comments on commit 04e0cf6

Please sign in to comment.