Newer
Older
#ifndef MANTID_DATAOBJECTS_MASKWORKSPACETEST_H
#define MANTID_DATAOBJECTS_MASKWORKSPACETEST_H
#include <cxxtest/TestSuite.h>
#include "MantidDataObjects/MaskWorkspace.h"
#include "MantidGeometry/Instrument.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"
class MaskWorkspaceTest : public CxxTest::TestSuite
{
public:
TS_ASSERT_THROWS_NOTHING(new Mantid::DataObjects::MaskWorkspace());
void test_constructor_using_length()
{
int nDetectors = 10;
Mantid::DataObjects::MaskWorkspace* maskWS = new Mantid::DataObjects::MaskWorkspace(nDetectors);
TS_ASSERT_EQUALS(maskWS->getNumberHistograms(), nDetectors);
TS_ASSERT_EQUALS(maskWS->blocksize(), 1);
TS_ASSERT_EQUALS(maskWS->getNumberMasked(), 0);
TS_ASSERT_THROWS(maskWS->isMasked(0), std::runtime_error);
}
void test_constructure_using_instrument()
{
int pixels = 10;
Mantid::Geometry::Instrument_sptr inst =
ComponentCreationHelper::createTestInstrumentRectangular2(1,pixels);
inst->setName("MaskWorkspaceTest_Instrument");
Mantid::DataObjects::MaskWorkspace* maskWS =
new Mantid::DataObjects::MaskWorkspace(inst, false);
for (int i = 0; i < pixels; i++)
maskWS->setValue(i, 1); // mask the pixel
TS_ASSERT_EQUALS(maskWS->getNumberHistograms(), pixels*pixels);
TS_ASSERT_EQUALS(maskWS->getNumberMasked(), pixels);
TS_ASSERT(maskWS->isMasked(0));
void test_mask_accessors()
{
int pixels = 10;
int maskpixels = 25;
Mantid::Geometry::Instrument_sptr inst =
ComponentCreationHelper::createTestInstrumentRectangular2(1,pixels);
inst->setName("MaskWorkspaceTest_Accessors");
Mantid::DataObjects::MaskWorkspace* maskWS =
new Mantid::DataObjects::MaskWorkspace(inst, false);
for (int i = 0; i < maskpixels; i++)
maskWS->setMasked(i); // mask the pixel
TS_ASSERT_EQUALS(maskWS->getNumberHistograms(), pixels*pixels);
TS_ASSERT_EQUALS(maskWS->getNumberMasked(), maskpixels);
TS_ASSERT(maskWS->isMasked(0));
TS_ASSERT_EQUALS(maskWS->isMasked(maskpixels), false); // one past the masked ones
maskWS->setMasked(0, false);
TS_ASSERT_EQUALS(maskWS->isMasked(0), false);
}
};
#endif // MANTID_DATAOBJECTS_MASKWORKSPACETEST_H