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 +
Sofia Antony
committed
#ifndef DATEVALIDATORTEST_H_
#define DATEVALIDATORTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/DateValidator.h"
using namespace Mantid::Kernel;
class DateValidatorTest : public CxxTest::TestSuite {
Sofia Antony
committed
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")
Sofia Antony
committed
}
void testInvalidaDate() {
/*std::string s;
std::getline(std::cin,s);*/
Sofia Antony
committed
DateValidator v;
TS_ASSERT_EQUALS(
v.isValid("32/10/2009"),
"Invalid Date:Day part of the Date parameter must be between 1 and 31")
Sofia Antony
committed
TS_ASSERT_EQUALS(v.isValid("12/101/2009"), "Invalid Date:Month part of the "
"Date parameter must be between "
"1 and 12")
Sofia Antony
committed
TS_ASSERT_EQUALS(v.isValid("12/10/2112"), "Invalid Date:Year part of the "
"Date parameter can not be "
"greater than the current year")
Sofia Antony
committed
}
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"), "")
Sofia Antony
committed
}
};
#endif /*DATEVALIDATORTEST_H_*/