Skip to content

Commit

Permalink
refs #4150. Fix slicing issue by introducing v-destructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Nov 25, 2011
1 parent b16dbab commit 447885a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
23 changes: 9 additions & 14 deletions Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,11 @@ class MatrixWorkspaceTest : public CxxTest::TestSuite
MockNearestNeighboursFactory* factory = new MockNearestNeighboursFactory;
EXPECT_CALL(*factory, create(_,_,_)).Times(1).WillOnce(Return(product));

//Scoped block to ensure factory and generated products die with workspace
{
WorkspaceTester wkspace(factory);
wkspace.initialize(1,4,3);
wkspace.getNeighboursExact(0, 1); //First call should construct nearest neighbours before calling ::neighbours
wkspace.getNeighboursExact(0, 1); //Second call should not construct nearest neighbours before calling ::neighbours
}
WorkspaceTester wkspace(factory);
wkspace.initialize(1,4,3);
wkspace.getNeighboursExact(0, 1); //First call should construct nearest neighbours before calling ::neighbours
wkspace.getNeighboursExact(0, 1); //Second call should not construct nearest neighbours before calling ::neighbours

}

void test_get_neighbours_radius()
Expand All @@ -460,13 +458,10 @@ class MatrixWorkspaceTest : public CxxTest::TestSuite
MockNearestNeighboursFactory* factory = new MockNearestNeighboursFactory;
EXPECT_CALL(*factory, create(_,_,_)).Times(1).WillOnce(Return(product));

//Scoped block to ensure factory and generated products die with workspace
{
WorkspaceTester wkspace(factory);
wkspace.initialize(1,4,3);
wkspace.getNeighbours(0, 1); //First call should construct nearest neighbours before calling ::neighbours
wkspace.getNeighbours(0, 1); //Second call should not construct nearest neighbours before calling ::neighbours
}
WorkspaceTester wkspace(factory);
wkspace.initialize(1,4,3);
wkspace.getNeighbours(0, 1); //First call should construct nearest neighbours before calling ::neighbours
wkspace.getNeighbours(0, 1); //Second call should not construct nearest neighbours before calling ::neighbours
}

void test_reset_neighbours()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace Mantid
/// Factory method
virtual INearestNeighbours* create(boost::shared_ptr<const Instrument> instrument,
const ISpectraDetectorMap & spectraMap, bool ignoreMasked=false) = 0;
/// Destructor
virtual ~INearestNeighboursFactory(){};
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class MockNearestNeighboursFactory : public Mantid::Geometry::INearestNeighbours
{
public:
MOCK_METHOD3(create, Mantid::Geometry::INearestNeighbours*(boost::shared_ptr<const Mantid::Geometry::Instrument>,const Mantid::Geometry::ISpectraDetectorMap&, bool));
~MockNearestNeighboursFactory(){}
virtual ~MockNearestNeighboursFactory()
{
}
};

//Helper typedef and type for mocking NearestNeighbour map usage.
Expand Down

0 comments on commit 447885a

Please sign in to comment.