Commit 308603cd authored by Samuel Jackson's avatar Samuel Jackson
Browse files

Refs #20441 Add test cases

parent e73221b8
......@@ -796,6 +796,8 @@ double Peak::getSigmaIntensity() const { return m_sigmaIntensity; }
/** Return the peak intensity divided by the error in the intensity */
double Peak::getIntensityOverSigma() const {
if (m_sigmaIntensity == 0)
return 0;
return m_intensity / m_sigmaIntensity;
}
......
......@@ -556,6 +556,45 @@ public:
TS_ASSERT(Mock::VerifyAndClearExpectations(replacementShape));
}
void test_get_intensity_over_sigma() {
const int detectorId = 19999;
const double wavelength = 2;
const double intensity {100};
const double sigma {10};
Peak p(inst, detectorId, wavelength);
p.setIntensity(intensity);
p.setSigmaIntensity(sigma);
TS_ASSERT_EQUALS(p.getIntensityOverSigma(), intensity/sigma);
}
void test_get_intensity_over_sigma_empty_sigma() {
const int detectorId = 19999;
const double wavelength = 2;
const double intensity {0};
const double sigma {0};
Peak p(inst, detectorId, wavelength);
p.setIntensity(intensity);
p.setSigmaIntensity(sigma);
TS_ASSERT_DELTA(p.getIntensityOverSigma(), 0, 1e-10);
}
void test_get_energy() {
const int detectorId = 19999;
const double wavelength = 2;
const double initialEnergy{100};
const double finalEnergy{110};
Peak p(inst, detectorId, wavelength);
p.setInitialEnergy(initialEnergy);
p.setFinalEnergy(finalEnergy);
TS_ASSERT_EQUALS(p.getEnergy(), initialEnergy - finalEnergy);
}
private:
void check_Contributing_Detectors(const Peak &peak,
const std::vector<int> &expected) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment