Skip to content

Commit

Permalink
Re #8357. Eliminate memory leaks in tests.
Browse files Browse the repository at this point in the history
By calling delete where appropriate.
  • Loading branch information
RussellTaylor committed Mar 19, 2014
1 parent 4b45a32 commit a295915
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/AlgorithmHistoryTest.h
Expand Up @@ -72,7 +72,7 @@ class AlgorithmHistoryTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(compareAlg->getPropertyValue("arg2_param"), "5");

Mantid::API::AlgorithmFactory::Instance().unsubscribe("testalg1",1);

delete testInput;
}

private:
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/test/ExperimentInfoTest.h
Expand Up @@ -315,6 +315,7 @@ class ExperimentInfoTest : public CxxTest::TestSuite

ExperimentInfo * ws2 = ws.cloneExperimentInfo();
do_compare_ExperimentInfo(ws,*ws2);
delete ws2;
}

void test_clone_then_copy()
Expand All @@ -335,6 +336,8 @@ class ExperimentInfoTest : public CxxTest::TestSuite
ws3.copyExperimentInfoFrom(ws2);

do_compare_ExperimentInfo(ws,ws3);

delete ws2;
}

void test_default_emode_is_elastic()
Expand Down
Expand Up @@ -86,6 +86,7 @@ class MatrixWorkspaceMDIteratorTest : public CxxTest::TestSuite
TS_ASSERT_DELTA( it->getError(), 22.0, 1e-5);
TS_ASSERT_DELTA( it->getCenter()[0], 3.0, 1e-5);
TS_ASSERT_DELTA( it->getCenter()[1], 2.0, 1e-5);
delete it;
}


Expand All @@ -94,7 +95,9 @@ class MatrixWorkspaceMDIteratorTest : public CxxTest::TestSuite
{
boost::shared_ptr<MatrixWorkspace> ws = makeFakeWS();
// The number of output cannot be larger than the number of histograms
TS_ASSERT_EQUALS( ws->createIterators(10, NULL).size(), 4);
std::vector<IMDIterator*> it = ws->createIterators(10, NULL);
TS_ASSERT_EQUALS( it.size(), 4);
for ( size_t i = 0; i < it.size(); ++i ) delete it[i];

// Split in 4 iterators
std::vector<IMDIterator*> iterators = ws->createIterators(4, NULL);
Expand All @@ -117,6 +120,7 @@ class MatrixWorkspaceMDIteratorTest : public CxxTest::TestSuite
TS_ASSERT( it->next() );
TS_ASSERT( it->next() );
TS_ASSERT( !it->next() );
delete it;
}
}

Expand All @@ -130,6 +134,7 @@ class MatrixWorkspaceMDIteratorTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(det->isMasked(), it->getIsMasked());
it->next();
}
delete it;
}


Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/test/SpectraAxisTest.h
Expand Up @@ -32,6 +32,7 @@ class SpectraAxisTest : public CxxTest::TestSuite
~SpectraAxisTest()
{
delete spectraAxis;
delete ws;
}

void testConstructor()
Expand Down

0 comments on commit a295915

Please sign in to comment.