forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LogarithmicGeneratorTest.h
49 lines (40 loc) · 1.73 KB
/
LogarithmicGeneratorTest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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 & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include <cxxtest/TestSuite.h>
#include "MantidHistogramData/LogarithmicGenerator.h"
#include <algorithm>
using Mantid::HistogramData::LogarithmicGenerator;
class LogarithmicGeneratorTest : 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 LogarithmicGeneratorTest *createSuite() { return new LogarithmicGeneratorTest(); }
static void destroySuite(LogarithmicGeneratorTest *suite) { delete suite; }
void test_length0() {
std::vector<double> x(0);
std::generate_n(x.begin(), 0, LogarithmicGenerator(0.1, 2.0));
TS_ASSERT_EQUALS(x, std::vector<double>(0));
}
void test_length1() {
std::vector<double> x(1);
std::generate_n(x.begin(), 1, LogarithmicGenerator(0.1, 2.0));
TS_ASSERT_EQUALS(x, std::vector<double>{0.1});
}
void test_length2() {
std::vector<double> x(2);
std::generate_n(x.begin(), 2, LogarithmicGenerator(0.1, 2.0));
TS_ASSERT_DELTA(x, std::vector<double>({0.1, 0.3}), 1e-14);
}
void test_length4() {
std::vector<double> x(4);
std::generate_n(x.begin(), 4, LogarithmicGenerator(0.1, 1.0));
TS_ASSERT_DELTA(x, std::vector<double>({0.1, 0.2, 0.4, 0.8}), 1e-14);
std::generate_n(x.begin(), 4, LogarithmicGenerator(0.1, 2.0));
TS_ASSERT_DELTA(x, std::vector<double>({0.1, 0.3, 0.9, 2.7}), 1e-14);
}
};