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 +
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
#ifndef ARRAYBOUNDEDVALIDATORTEST_H_
#define ARRAYBOUNDEDVALIDATORTEST_H_
#include "MantidKernel/ArrayOrderedPairsValidator.h"
#include "MantidKernel/BoundedValidator.h"
#include <cxxtest/TestSuite.h>
#include <string>
#include <vector>
using namespace Mantid::Kernel;
using namespace std;
class ArrayOrderedPairsValidatorTest : public CxxTest::TestSuite {
public:
void test_double_clone() {
IValidator_sptr vd(new ArrayOrderedPairsValidator<double>());
IValidator_sptr vvd = vd->clone();
TS_ASSERT_DIFFERS(vd, vvd);
}
void test_int_clone() {
IValidator_sptr vi(new ArrayOrderedPairsValidator<int>);
IValidator_sptr vvi = vi->clone();
TS_ASSERT_DIFFERS(vi, vvi);
}
void test_array_validation() {
std::vector<int> vec{1, 5, 2, 3, 10, 10};
ArrayOrderedPairsValidator<int> validator;
TS_ASSERT_EQUALS(validator.isValid(vec), "");
}
void test_array_validation_unordered() {
std::vector<int> vec{10, 5, 3, 2, 10, 10};
ArrayOrderedPairsValidator<int> validator;
TS_ASSERT_EQUALS(
validator.isValid(vec),
"Pair (10, 5) is not ordered.\nPair (3, 2) is not ordered.\n");
}
void test_array_validation_odd() {
std::vector<int> vec{1, 5, 2, 3, 10};
ArrayOrderedPairsValidator<int> validator;
TS_ASSERT_EQUALS(validator.isValid(vec),
"Array has an odd number of entries (5).");
}
};
#endif // ARRAYBOUNDEDVALIDATORTEST_H_