forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MDDimensionStatsTest.h
38 lines (32 loc) · 1.15 KB
/
MDDimensionStatsTest.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
// 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 "MantidDataObjects/MDDimensionStats.h"
#include "MantidKernel/Timer.h"
#include <cxxtest/TestSuite.h>
using Mantid::DataObjects::MDDimensionStats;
class MDDimensionStatsTest : public CxxTest::TestSuite {
public:
void test_constructor() {
MDDimensionStats s;
TS_ASSERT_EQUALS(s.total, 0.0);
TS_ASSERT_EQUALS(s.totalApproxVariance, 0.0);
TS_ASSERT_EQUALS(s.numPoints, 0);
}
void test_addPoint() {
MDDimensionStats s;
s.addPoint(10.0);
TS_ASSERT_DELTA(s.getMean(), 10.0, 1e-4);
TS_ASSERT_DELTA(s.getApproxVariance(), 0.0, 1e-4);
s.addPoint(0.0);
TS_ASSERT_DELTA(s.getMean(), 5.0, 1e-4);
TS_ASSERT_DELTA(s.getApproxVariance(), 25.0 / 2.0, 1e-4);
s.addPoint(5.0);
TS_ASSERT_DELTA(s.getMean(), 5.0, 1e-4);
TS_ASSERT_DELTA(s.getApproxVariance(), 25.0 / 3.0, 1e-4);
}
};