Engauge Digitizer  2
TestValidators.cpp
Go to the documentation of this file.
2 #include "DlgValidatorDateTime.h"
4 #include "DlgValidatorNumber.h"
5 #include "Logger.h"
6 #include "MainWindow.h"
7 #include <QtTest/QtTest>
8 #include "Test/TestValidators.h"
9 
10 QTEST_MAIN (TestValidators)
11 
12 TestValidators::TestValidators(QObject *parent) :
13  QObject(parent)
14 {
15 }
16 
17 void TestValidators::cleanupTestCase ()
18 {
19 }
20 
21 void TestValidators::initTestCase ()
22 {
23  const bool NO_DROP_REGRESSION = false;
24  const QString NO_ERROR_REPORT_LOG_FILE;
25  const QString NO_REGRESSION_OPEN_FILE;
26  const bool NO_GNUPLOT_LOG_FILES = false;
27  const bool NO_REGRESSION_IMPORT = false;
28  const bool NO_RESET = false;
29  const bool NO_EXPORT_ONLY = false;
30  const bool NO_EXTRACT_IMAGE_ONLY = false;
31  const QString NO_EXTRACT_IMAGE_EXTENSION;
32  const bool DEBUG_FLAG = false;
33  const QStringList NO_LOAD_STARTUP_FILES;
34  const QStringList NO_COMMAND_LINE;
35 
36  initializeLogging ("engauge_test",
37  "engauge_test.log",
38  DEBUG_FLAG);
39 
45  NO_RESET,
51  w.show ();
52 }
53 
54 bool TestValidators::stateDateTime (const QString &string,
55  QValidator::State expectedState)
56 {
57  int pos;
58 
62 
63  QString stringLocal = string;
64  return (validator.validate (stringLocal,
65  pos) == expectedState);
66 }
67 
68 bool TestValidators::stateDegreesMinutesSeconds (const QString &string,
69  QValidator::State expectedState)
70 {
71  int pos;
72 
74 
75  QString stringLocal = string;
76  return (validator.validate (stringLocal,
77  pos) == expectedState);
78 }
79 
80 bool TestValidators::stateNumber(const QString &string,
81  QValidator::State expectedState)
82 {
83  int pos;
84  const QLocale locale;
85 
87  locale);
88 
89  QString stringLocal = string;
90  return (validator.validate (stringLocal,
91  pos) == expectedState);
92 }
93 
94 void TestValidators::testDateTimeDate ()
95 {
96  QVERIFY (stateDateTime ("2015/01/02", QValidator::Acceptable));
97 }
98 
99 void TestValidators::testDateTimeDateTime ()
100 {
101  QVERIFY (stateDateTime ("2015/01/02 01:02:03", QValidator::Acceptable));
102 }
103 
104 void TestValidators::testDateTimeDateTimePm ()
105 {
106  QVERIFY (stateDateTime ("2015/01/02 01:02:03 PM", QValidator::Acceptable));
107 }
108 
109 void TestValidators::testDateTimeTime ()
110 {
111  QVERIFY (stateDateTime ("01:02:03", QValidator::Acceptable));
112 }
113 
114 void TestValidators::testDegreesMinutesSecondsDegrees ()
115 {
116  QVERIFY (stateDegreesMinutesSeconds ("180", QValidator::Acceptable));
117 }
118 
119 void TestValidators::testDegreesMinutesSecondsDegreesMinutes ()
120 {
121  QVERIFY (stateDegreesMinutesSeconds ("180 10", QValidator::Acceptable));
122 }
123 
124 void TestValidators::testDegreesMinutesSecondsDegreesMinutesSeconds ()
125 {
126  QVERIFY (stateDegreesMinutesSeconds ("180 10 20", QValidator::Acceptable));
127 }
128 
129 void TestValidators::testNumberInteger ()
130 {
131  QVERIFY (stateNumber ("1", QValidator::Acceptable));
132 }
133 
134 void TestValidators::testNumberReal ()
135 {
136  QVERIFY (stateNumber ("1.1", QValidator::Acceptable));
137 }
138 
139 void TestValidators::testNumberRealBad ()
140 {
141  QVERIFY (stateNumber ("1.1.", QValidator::Invalid));
142 }
Validator for numeric value expressed as date and/or time.
const bool NO_GNUPLOT_LOG_FILES
Definition: TestExport.cpp:29
const bool NO_REGRESSION_IMPORT
Definition: TestExport.cpp:30
const QString NO_EXTRACT_IMAGE_EXTENSION
Definition: TestExport.cpp:34
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
Definition: Logger.cpp:21
const QStringList NO_LOAD_STARTUP_FILES
Definition: TestExport.cpp:36
const QString NO_REGRESSION_OPEN_FILE
Definition: TestExport.cpp:28
Validator for angles in real degrees, integer degrees and real minutes, or integer degrees with integ...
const bool NO_EXPORT_ONLY
Definition: TestExport.cpp:32
const QStringList NO_COMMAND_LINE
Definition: TestExport.cpp:37
const bool NO_DROP_REGRESSION
Definition: TestExport.cpp:24
const QString NO_ERROR_REPORT_LOG_FILE
Definition: TestExport.cpp:27
Unit tests of validators.
const bool DEBUG_FLAG
Definition: TestExport.cpp:35
Validator for generic (=simple) numbers.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:91
const bool NO_EXTRACT_IMAGE_ONLY
Definition: TestExport.cpp:33