"source/adios2/git@code.ornl.gov:pnb/ADIOS2.git" did not exist on "1bc215151cb2ad0008ed4e1df4be6f94db5ce8a6"
Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_KERNEL_DIFFRACTIONTEST_H_
#define MANTID_KERNEL_DIFFRACTIONTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/Diffraction.h"
using Mantid::Kernel::Diffraction::calcTofMax;
namespace { // anonymous
const double DIFC = 2100.; // sensible value
const double TZERO = 10.;
// intentionally goofy - reduces tzero by 1
const double DIFA1 = .25 * DIFC * DIFC;
// intentionally goofy - reduces tzero by .01
const double DIFA2 = 25 * DIFC * DIFC;
// intentionally goofy
const double DIFA3 = -.25 * DIFC * DIFC;
class DiffractionTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static DiffractionTest *createSuite() { return new DiffractionTest(); }
static void destroySuite(DiffractionTest *suite) { delete suite; }
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
void test_calcTofMin() {
const double TMIN = 300.;
// just difc
TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., 0.), 0.);
TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., 0., TMIN), TMIN);
// difc + tzero
TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., TZERO, 0.), TZERO);
TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., TZERO, TMIN), TMIN);
// difc + difa + tzero
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, 0., 0.), 0.);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, 0., TMIN), TMIN);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, TZERO, 0.), TZERO - 1.);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, TZERO, TMIN), TMIN);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, 0., 0.), 0.);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, 0., TMIN), TMIN);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, TZERO, 0.), TZERO - .01);
TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, TZERO, TMIN), TMIN);
}
void test_calcTofMax() {
const double TMAX = 16666.7;
const double TSUPERMAX = std::numeric_limits<double>::max();
// just difc
TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., 0., TMAX), TMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., 0., TSUPERMAX), TSUPERMAX);
// difc + tzero
TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., TZERO, TMAX), TMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., TZERO, TSUPERMAX), TSUPERMAX);
// difc + difa + tzero
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, 0., TMAX), TMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, 0., TSUPERMAX), TSUPERMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, TZERO, TMAX), TMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, TZERO, TSUPERMAX), TSUPERMAX);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, 0., TMAX), 0.);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, 0., TSUPERMAX), 0.);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, TZERO, TMAX), TZERO - 1.);
TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, TZERO, TSUPERMAX), TZERO - 1.);
}
#endif /* MANTID_KERNEL_DIFFRACTIONTEST_H_ */