1 #include "CoordUnitsNonPolarTheta.h" 2 #include "DlgValidatorDateTime.h" 3 #include "DlgValidatorDegreesMinutesSeconds.h" 4 #include "DlgValidatorNumber.h" 6 #include "MainWindow.h" 7 #include <QtTest/QtTest> 8 #include "Test/TestValidators.h" 17 void TestValidators::cleanupTestCase ()
21 void TestValidators::initTestCase ()
23 const QString NO_ERROR_REPORT_LOG_FILE;
24 const QString NO_REGRESSION_OPEN_FILE;
25 const bool NO_GNUPLOT_LOG_FILES =
false;
26 const bool NO_REGRESSION_IMPORT =
false;
27 const bool NO_RESET =
false;
28 const bool DEBUG_FLAG =
false;
29 const QStringList NO_LOAD_STARTUP_FILES;
31 initializeLogging (
"engauge_test",
36 NO_REGRESSION_OPEN_FILE,
40 NO_LOAD_STARTUP_FILES);
44 bool TestValidators::stateDateTime (
const QString &
string,
45 QValidator::State expectedState)
50 COORD_UNITS_DATE_YEAR_MONTH_DAY,
51 COORD_UNITS_TIME_HOUR_MINUTE_SECOND);
53 QString stringLocal = string;
54 return (validator.
validate (stringLocal,
55 pos) == expectedState);
58 bool TestValidators::stateDegreesMinutesSeconds (
const QString &
string,
59 QValidator::State expectedState)
65 QString stringLocal = string;
66 return (validator.
validate (stringLocal,
67 pos) == expectedState);
70 bool TestValidators::stateNumber(
const QString &
string,
71 QValidator::State expectedState)
79 QString stringLocal = string;
80 return (validator.
validate (stringLocal,
81 pos) == expectedState);
84 void TestValidators::testDateTimeDate ()
86 QVERIFY (stateDateTime (
"2015/01/02", QValidator::Acceptable));
89 void TestValidators::testDateTimeDateTime ()
91 QVERIFY (stateDateTime (
"2015/01/02 01:02:03", QValidator::Acceptable));
94 void TestValidators::testDateTimeDateTimePm ()
96 QVERIFY (stateDateTime (
"2015/01/02 01:02:03 PM", QValidator::Acceptable));
99 void TestValidators::testDateTimeTime ()
101 QVERIFY (stateDateTime (
"01:02:03", QValidator::Acceptable));
104 void TestValidators::testDegreesMinutesSecondsDegrees ()
106 QVERIFY (stateDegreesMinutesSeconds (
"180", QValidator::Acceptable));
109 void TestValidators::testDegreesMinutesSecondsDegreesMinutes ()
111 QVERIFY (stateDegreesMinutesSeconds (
"180 10", QValidator::Acceptable));
114 void TestValidators::testDegreesMinutesSecondsDegreesMinutesSeconds ()
116 QVERIFY (stateDegreesMinutesSeconds (
"180 10 20", QValidator::Acceptable));
119 void TestValidators::testNumberInteger ()
121 QVERIFY (stateNumber (
"1", QValidator::Acceptable));
124 void TestValidators::testNumberReal ()
126 QVERIFY (stateNumber (
"1.1", QValidator::Acceptable));
129 void TestValidators::testNumberRealBad ()
131 QVERIFY (stateNumber (
"1.1.", QValidator::Invalid));
Validator for numeric value expressed as date and/or time.
Validator for angles in real degrees, integer degrees and real minutes, or integer degrees with integ...
virtual QValidator::State validate(QString &input, int &pos) const
Validate according to the numeric format specific to the leaf class.
virtual QValidator::State validate(QString &input, int &pos) const
Validate according to the numeric format specific to the leaf class.
Unit tests of validators.
virtual QValidator::State validate(QString &input, int &pos) const
Apply the standard validation with 0 as the exclusive minimum. Call setCoordScale just before calling...
Validator for generic (=simple) numbers.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...