diff --git a/Code/Mantid/Framework/DataObjects/src/CoordTransformDistance.cpp b/Code/Mantid/Framework/DataObjects/src/CoordTransformDistance.cpp index ee41225d0459..ed863adc5c26 100644 --- a/Code/Mantid/Framework/DataObjects/src/CoordTransformDistance.cpp +++ b/Code/Mantid/Framework/DataObjects/src/CoordTransformDistance.cpp @@ -112,7 +112,7 @@ std::string CoordTransformDistance::toXMLString() const { AutoPtr coordTransformTypeElement = pDoc->createElement("Type"); coordTransformTypeElement->appendChild( - pDoc->createTextNode("CoordTransformDistance")); + AutoPtr(pDoc->createTextNode("CoordTransformDistance"))); coordTransformElement->appendChild(coordTransformTypeElement); AutoPtr paramListElement = pDoc->createElement("ParameterList"); diff --git a/Code/Mantid/Framework/DataObjects/test/CoordTransformDistanceTest.h b/Code/Mantid/Framework/DataObjects/test/CoordTransformDistanceTest.h index d014723917d3..fb87f3f7a955 100644 --- a/Code/Mantid/Framework/DataObjects/test/CoordTransformDistanceTest.h +++ b/Code/Mantid/Framework/DataObjects/test/CoordTransformDistanceTest.h @@ -9,6 +9,8 @@ #include #include "MantidAPI/CoordTransform.h" +#include + using namespace Mantid; using namespace Mantid::DataObjects; using Mantid::API::CoordTransform; @@ -30,13 +32,14 @@ class CoordTransformDistanceTest : public CxxTest::TestSuite bool used[4] = {true, false, true, true}; CoordTransformDistance ct(4, center, used); // A copy was made - TS_ASSERT_DIFFERS(ct.getCenter(), center); + const coord_t *transformCentres = ct.getCenter(); + TS_ASSERT_DIFFERS(transformCentres, center); + const bool * usedDims = ct.getDimensionsUsed(); TS_ASSERT_DIFFERS(ct.getDimensionsUsed(), used); - // Contents are good compare(4, center, ct.getCenter()); for (size_t i=0; i<4; i++) - TS_ASSERT_EQUALS( used[i], ct.getDimensionsUsed()[i]); + TS_ASSERT_EQUALS( used[i], usedDims[i]); } @@ -48,7 +51,7 @@ class CoordTransformDistanceTest : public CxxTest::TestSuite bool used[2] = {true, true}; CoordTransformDistance ct(2,center,used); - CoordTransform * clone = ct.clone(); + boost::scoped_ptr clone(ct.clone()); coord_t out = 0; coord_t in1[2] = {0, 3}; TS_ASSERT_THROWS_NOTHING( clone->apply(in1, &out) ); diff --git a/Code/Mantid/Framework/DataObjects/test/MDBoxIteratorTest.h b/Code/Mantid/Framework/DataObjects/test/MDBoxIteratorTest.h index 813299daa615..2ace33cd724b 100644 --- a/Code/Mantid/Framework/DataObjects/test/MDBoxIteratorTest.h +++ b/Code/Mantid/Framework/DataObjects/test/MDBoxIteratorTest.h @@ -79,6 +79,12 @@ class MDBoxIteratorTest : public CxxTest::TestSuite D212 = dynamic_cast(C21->getChild(2)); D213 = dynamic_cast(C21->getChild(3)); } + + void tearDown() + { + delete A->getBoxController(); + delete A; + } //-------------------------------------------------------------------------------------- void test_ctor_with_null_box_fails() @@ -125,6 +131,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Calling next again does not cause problems. TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_depth_limit_1() @@ -138,6 +146,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, B3) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_depth_limit_0() @@ -147,6 +157,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT_EQUALS( it->getBox(), A); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_starting_deeper() @@ -160,6 +172,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, C03) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only() @@ -184,6 +198,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only_depth_2() @@ -204,6 +220,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, B3) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only_depth_1() @@ -217,6 +235,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, B3) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only_depth_0() @@ -227,6 +247,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT_EQUALS( it->getBox(), A); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only_starting_deeper() @@ -242,6 +264,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, C23) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_leaf_only_starting_deeper_depth_limited() @@ -254,6 +278,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TS_ASSERT( nextIs(it, C23) ); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } //-------------------------------------------------------------------------------------- @@ -271,6 +297,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite BoxController *const bc = A->getBoxController(); delete bc; + delete it; + delete A; } //-------------------------------------------------------------------------------------- @@ -302,7 +330,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite BoxController *const bc = A->getBoxController(); delete bc; - + delete it; + delete A; } //-------------------------------------------------------------------------------------- void test_iterator_withImplicitFunction_above11() @@ -314,6 +343,7 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, false, func); + delete func; // Start with the top one TS_ASSERT_EQUALS( it->getBox(), A); @@ -335,6 +365,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } //-------------------------------------------------------------------------------------- @@ -347,6 +379,7 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, true, func); + delete func; // C00-C01 are outside the range, so the first one is C02 TS_ASSERT_EQUALS( it->getBox(), C02); @@ -363,6 +396,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } @@ -376,6 +411,7 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, false, func); + delete func; // Start with the top one TS_ASSERT_EQUALS( it->getBox(), A); @@ -394,6 +430,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } @@ -408,6 +446,7 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, false, func); + delete func; // Go down to the only two leaf boxes that are in range TS_ASSERT_EQUALS( it->getBox(), A); @@ -418,6 +457,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } //-------------------------------------------------------------------------------------- @@ -431,6 +472,7 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, true, func); + delete func; // Only two leaf boxes are in range TS_ASSERT_EQUALS( it->getBox(), D211); @@ -438,6 +480,8 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // No more! TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } //-------------------------------------------------------------------------------------- @@ -449,11 +493,14 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, false, func); + delete func; // Returns the first box but that's it TS_ASSERT_EQUALS( it->getBox(), A); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } //-------------------------------------------------------------------------------------- @@ -465,10 +512,14 @@ class MDBoxIteratorTest : public CxxTest::TestSuite // Create an iterator it = new MDBoxIterator,1>(A, 20, true, func); + delete func; + // Nothing in the iterator! TS_ASSERT_EQUALS( it->getDataSize(), 0); TS_ASSERT( !it->next() ); TS_ASSERT( !it->next() ); + + delete it; } void test_getIsMasked() @@ -542,6 +593,9 @@ class MDBoxIteratorTest : public CxxTest::TestSuite TSM_ASSERT_EQUALS("Should NOT have skipped to the second box", 2, evaluationIterator->getPosition()); TS_ASSERT_THROWS_NOTHING(evaluationIterator->next()); TSM_ASSERT_EQUALS("Should NOT have skipped to the third box", 3, evaluationIterator->getPosition()); + + delete setupIterator; + delete evaluationIterator; } void test_custom_skipping_policy() diff --git a/Code/Mantid/Framework/DataObjects/test/MDBoxTest.h b/Code/Mantid/Framework/DataObjects/test/MDBoxTest.h index be79dd888761..65cf4d1f6ed9 100644 --- a/Code/Mantid/Framework/DataObjects/test/MDBoxTest.h +++ b/Code/Mantid/Framework/DataObjects/test/MDBoxTest.h @@ -390,10 +390,10 @@ static void destroySuite(MDBoxTest * suite) { delete suite; } b.addEvent(ev); b.addEvent(ev); b.addEvent(ev); - std::vector > * events; - events = b.getEventsCopy(); + std::vector > * events = b.getEventsCopy(); TS_ASSERT_EQUALS( events->size(), 3); TS_ASSERT_EQUALS( (*events)[2].getSignal(), 4.0); + delete events; } void test_sptr()