forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DateValidatorTest.h
45 lines (36 loc) · 1.57 KB
/
DateValidatorTest.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
// 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 "MantidKernel/DateValidator.h"
using namespace Mantid::Kernel;
class DateValidatorTest : public CxxTest::TestSuite {
public:
void testInValidFormat() {
DateValidator v;
TS_ASSERT_EQUALS(v.isValid("ddmmyyyy"), "Invalid Date:date format must be DD/MM/YYYY")
TS_ASSERT_EQUALS(v.isValid("dd/mm:yyyy"), "Invalid Date")
}
void testInvalidaDate() {
/*std::string s;
std::getline(std::cin,s);*/
DateValidator v;
TS_ASSERT_EQUALS(v.isValid("32/10/2009"), "Invalid Date:Day part of the Date parameter must be between 1 and 31")
TS_ASSERT_EQUALS(v.isValid("12/101/2009"), "Invalid Date:Month part of the "
"Date parameter must be between "
"1 and 12")
TS_ASSERT_EQUALS(v.isValid("12/10/2112"), "Invalid Date:Year part of the "
"Date parameter can not be "
"greater than the current year")
}
void testValidDate() {
DateValidator v;
TS_ASSERT_EQUALS(v.isValid(""), "") // empty date is allowed
TS_ASSERT_EQUALS(v.isValid("12/11/2009"), "")
TS_ASSERT_EQUALS(v.isValid("22/01/2006"), "")
}
};