forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BinEdgesTest.h
67 lines (57 loc) · 2.22 KB
/
BinEdgesTest.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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/BinEdges.h"
#include "MantidHistogramData/Points.h"
using namespace Mantid;
using namespace HistogramData;
class BinEdgesTest : 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 BinEdgesTest *createSuite() { return new BinEdgesTest(); }
static void destroySuite(BinEdgesTest *suite) { delete suite; }
void test_has_correct_mixins() {
BinEdges data;
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG((dynamic_cast<detail::VectorOf<BinEdges, HistogramX> &>(data))));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Iterable<BinEdges> &>(data)));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Offsetable<BinEdges> &>(data)));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Scalable<BinEdges> &>(data)));
}
void test_default_constructor() {
const BinEdges edges{};
TS_ASSERT(!edges);
}
void test_construct_from_null_Points() {
const Points points{};
const BinEdges edges(points);
TS_ASSERT(!edges);
}
void test_construct_from_empty_Points() {
Points points(0);
BinEdges edges(points);
TS_ASSERT_EQUALS(edges.size(), 0);
}
void test_construct_from_length1_Points() {
const Points points = {1.0};
const BinEdges edges(points);
TS_ASSERT_EQUALS(edges.size(), 2);
TS_ASSERT_DELTA(edges[0], 0.5, 1e-14);
TS_ASSERT_DELTA(edges[1], 1.5, 1e-14);
}
void test_construct_from_Points() {
Points points = {1.0, 3.0, 7.0, 15.0};
BinEdges edges(points);
TS_ASSERT_EQUALS(edges.size(), 5);
TS_ASSERT_DELTA(edges[0], 0.0, 1e-14);
TS_ASSERT_DELTA(edges[1], 2.0, 1e-14);
TS_ASSERT_DELTA(edges[2], 5.0, 1e-14);
TS_ASSERT_DELTA(edges[3], 11.0, 1e-14);
TS_ASSERT_DELTA(edges[4], 19.0, 1e-14);
}
};