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 DEBUG_FLAG =
false;
28 const QStringList NO_LOAD_STARTUP_FILES;
30 initializeLogging (
"engauge_test",
35 NO_REGRESSION_OPEN_FILE,
38 NO_LOAD_STARTUP_FILES);
42 bool TestValidators::stateDateTime (
const QString &
string,
43 QValidator::State expectedState)
48 COORD_UNITS_DATE_YEAR_MONTH_DAY,
49 COORD_UNITS_TIME_HOUR_MINUTE_SECOND);
51 QString stringLocal = string;
52 return (validator.
validate (stringLocal,
53 pos) == expectedState);
56 bool TestValidators::stateDegreesMinutesSeconds (
const QString &
string,
57 QValidator::State expectedState)
63 QString stringLocal = string;
64 return (validator.
validate (stringLocal,
65 pos) == expectedState);
68 bool TestValidators::stateNumber(
const QString &
string,
69 QValidator::State expectedState)
77 QString stringLocal = string;
78 return (validator.
validate (stringLocal,
79 pos) == expectedState);
82 void TestValidators::testDateTimeDate ()
84 QVERIFY (stateDateTime (
"2015/01/02", QValidator::Acceptable));
87 void TestValidators::testDateTimeDateTime ()
89 QVERIFY (stateDateTime (
"2015/01/02 01:02:03", QValidator::Acceptable));
92 void TestValidators::testDateTimeDateTimePm ()
94 QVERIFY (stateDateTime (
"2015/01/02 01:02:03 PM", QValidator::Acceptable));
97 void TestValidators::testDateTimeTime ()
99 QVERIFY (stateDateTime (
"01:02:03", QValidator::Acceptable));
102 void TestValidators::testDegreesMinutesSecondsDegrees ()
104 QVERIFY (stateDegreesMinutesSeconds (
"180", QValidator::Acceptable));
107 void TestValidators::testDegreesMinutesSecondsDegreesMinutes ()
109 QVERIFY (stateDegreesMinutesSeconds (
"180 10", QValidator::Acceptable));
112 void TestValidators::testDegreesMinutesSecondsDegreesMinutesSeconds ()
114 QVERIFY (stateDegreesMinutesSeconds (
"180 10 20", QValidator::Acceptable));
117 void TestValidators::testNumberInteger ()
119 QVERIFY (stateNumber (
"1", QValidator::Acceptable));
122 void TestValidators::testNumberReal ()
124 QVERIFY (stateNumber (
"1.1", QValidator::Acceptable));
127 void TestValidators::testNumberRealBad ()
129 QVERIFY (stateNumber (
"1.1.", QValidator::Invalid));
virtual QValidator::State validate(QString &input, int &pos) const
Validate according to the numeric format specific to the leaf class.
Validator for numeric value expressed as date and/or time.
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 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.
Unit tests of validators.
Validator for generic (=simple) numbers.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...