forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointsTest.h
62 lines (52 loc) · 2.05 KB
/
PointsTest.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
// 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 PointsTest : 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 PointsTest *createSuite() { return new PointsTest(); }
static void destroySuite(PointsTest *suite) { delete suite; }
void test_has_correct_mixins() {
Points data;
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG((dynamic_cast<detail::VectorOf<Points, HistogramX> &>(data))));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Iterable<Points> &>(data)));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Offsetable<Points> &>(data)));
TS_ASSERT_THROWS_NOTHING(UNUSED_ARG(dynamic_cast<detail::Scalable<Points> &>(data)));
}
void test_construct_default() {
const Points points{};
TS_ASSERT(!points);
}
void test_construct_from_null_BinEdges() {
const BinEdges edges{};
const Points points(edges);
TS_ASSERT(!points);
}
void test_construct_from_empty_BinEdges() {
const BinEdges edges(0);
const Points points(edges);
TS_ASSERT_EQUALS(points.size(), 0);
}
void test_construct_from_invalid_BinEdges() {
const BinEdges edges(1);
TS_ASSERT_THROWS(Points points(edges), const std::logic_error &);
}
void test_construct_from_BinEdges() {
const BinEdges edges{1.0, 3.0, 7.0, 15.0};
const Points points(edges);
TS_ASSERT_EQUALS(points.size(), 3);
TS_ASSERT_DELTA(points[0], 2.0, 1e-14);
TS_ASSERT_DELTA(points[1], 5.0, 1e-14);
TS_ASSERT_DELTA(points[2], 11.0, 1e-14);
}
};