1 #include "CurveConnectAs.h" 3 #include "DocumentModelExportFormat.h" 4 #include "ExportFileFunctions.h" 5 #include "ExportFileRelations.h" 6 #include "ExportValuesXOrY.h" 9 #include "MainWindow.h" 10 #include "MainWindowModel.h" 11 #include "PointStyle.h" 14 #include <QtTest/QtTest> 16 #include "SplinePair.h" 17 #include "Test/TestExport.h" 18 #include "Transformation.h" 24 const bool NOT_USING_GNUPLOT =
false;
32 bool TestExport::checkCommasInFunctionsForDelimiter (ExportDelimiter delimiter,
33 QLocale::Country country,
40 QTextStream str (&output);
47 unsigned int numWritesSoFar = 0;
50 exportFile.exportAllPerLineXThetaValuesMerged (m_modelExportOverride,
55 exportDelimiterToText (delimiter, NOT_USING_GNUPLOT),
70 bool TestExport::checkCommasInRelationsForDelimiter (ExportDelimiter delimiter,
71 QLocale::Country country,
78 QTextStream str (&output);
85 unsigned int numWritesSoFar = 0;
88 exportFile.exportAllPerLineXThetaValuesMerged (m_modelExportOverride,
92 exportDelimiterToText (delimiter, NOT_USING_GNUPLOT),
107 void TestExport::cleanupTestCase ()
111 void TestExport::initData (
bool isLog,
112 ExportDelimiter delimiter,
113 QLocale::Country country)
115 const QString CURVE_NAME (
"Curve1");
116 const int LINE_WIDTH = 2, POINT_LINE_WIDTH = 1;
117 const ColorPalette LINE_COLOR = COLOR_PALETTE_BLACK, POINT_COLOR = COLOR_PALETTE_BLACK;
118 const int RADIUS = 5;
121 m_document =
new Document (nullImage);
123 m_curvesIncluded.clear ();
124 m_curvesIncluded << CURVE_NAME;
129 CONNECT_AS_FUNCTION_SMOOTH),
134 curveStyles.setCurveStyle (CURVE_NAME, curveStyle);
154 m_modelMainWindow.
setLocale (QLocale::English,
168 m_xThetaValues.clear ();
169 m_xThetaValues << 0.0009999;
170 m_xThetaValues << 0.001;
171 m_xThetaValues << 0.01;
172 m_xThetaValues << 0.1;
174 m_xThetaValues << 10;
175 m_xThetaValues << 100;
176 m_xThetaValues << 1000;
177 QTransform matrixScreen ( 51, 52, 1123,
180 QTransform matrixGraph (qLn (0.001), qLn (0.001), qLn (1000),
181 qLn ( 1), qLn ( 100), qLn ( 1),
183 m_transformation.updateTransformFromMatrices (matrixScreen,
185 m_transformation.setModelCoords (m_modelCoords,
190 void TestExport::initTestCase ()
192 const QString NO_ERROR_REPORT_LOG_FILE;
193 const QString NO_REGRESSION_OPEN_FILE;
194 const bool NO_GNUPLOT_LOG_FILES =
false;
195 const bool NO_REGRESSION_IMPORT =
false;
196 const bool NO_RESET =
false;
197 const bool DEBUG_FLAG =
false;
198 const QStringList NO_LOAD_STARTUP_FILES;
200 initializeLogging (
"engauge_test",
205 NO_REGRESSION_OPEN_FILE,
206 NO_GNUPLOT_LOG_FILES,
207 NO_REGRESSION_IMPORT,
209 NO_LOAD_STARTUP_FILES);
214 void TestExport::testCommasInFunctionsForCommasSwitzerland ()
216 QString outputExpectedIfCommaSeparator =
218 "\"0,001\",\"-1,27563\"\n" 219 "\"0,001\",\"-1,27563\"\n" 220 "\"0,01\",\"-1,26683\"\n" 221 "\"0,1\",\"-1,17881\"\n" 223 "10,\"-706,15184\"\n" 224 "100,\"-3997814,14355\"\n" 225 "1000,\"-4541901224,06376\"\n";
226 QString outputExpectedIfPeriodSeparator =
234 "100,-3997814.14355\n" 235 "1000,-4541901224.06376\n";
238 bool success = checkCommasInFunctionsForDelimiter (EXPORT_DELIMITER_COMMA,
239 QLocale::Switzerland,
245 QVERIFY (outputGot == outputExpectedIfCommaSeparator ||
246 outputGot == outputExpectedIfPeriodSeparator);
249 void TestExport::testCommasInFunctionsForCommasUnitedStates ()
251 QString outputExpected =
259 "100,-3997814.14355\n" 260 "1000,-4541901224.06376\n";
263 bool success = checkCommasInFunctionsForDelimiter (EXPORT_DELIMITER_COMMA,
264 QLocale::UnitedStates,
270 QVERIFY (outputGot == outputExpected);
273 void TestExport::testCommasInFunctionsForTabsSwitzerland ()
275 QString outputExpectedIfCommaSeparator =
283 "100\t-3997814,14355\n" 284 "1000\t-4541901224,06376\n";
285 QString outputExpectedIfPeriodSeparator =
293 "100\t-3997814.14355\n" 294 "1000\t-4541901224.06376\n";
297 bool success = checkCommasInFunctionsForDelimiter (EXPORT_DELIMITER_TAB,
298 QLocale::Switzerland,
304 QVERIFY (outputGot == outputExpectedIfCommaSeparator ||
305 outputGot == outputExpectedIfPeriodSeparator);
308 void TestExport::testCommasInFunctionsForTabsUnitedStates ()
310 QString outputExpected =
318 "100\t-3997814.14355\n" 319 "1000\t-4541901224.06376\n";
322 bool success = checkCommasInFunctionsForDelimiter (EXPORT_DELIMITER_TAB,
323 QLocale::UnitedStates,
329 QVERIFY (outputGot == outputExpected);
332 void TestExport::testCommasInRelationsForCommasSwitzerland ()
334 QString outputExpectedIfCommaSeparator =
336 "\"3,3192\",\"2,08003\"\n" 337 "\"3,3723\",\"2,15796\"\n" 338 "\"3,432\",\"2,23368\"\n" 339 "\"3,4935\",\"2,30883\"\n" 340 "\"3,5539\",\"2,38438\"\n" 341 "\"3,6113\",\"2,46094\"\n" 342 "\"3,6687\",\"2,5375\"\n" 343 "\"3,7261\",\"2,61406\"\n" 344 "\"3,7836\",\"2,69062\"\n" 345 "\"3,841\",\"2,76718\"\n" 346 "\"3,9012\",\"2,84276\"\n" 347 "\"3,9628\",\"2,91791\"\n" 348 "\"4,0231\",\"2,99345\"\n" 349 "\"4,0785\",\"3,07067\"\n" 350 "\"4,1339\",\"3,14789\"\n" 351 "\"4,1932\",\"3,22378\"\n" 352 "\"4,2547\",\"3,29893\"\n" 353 "\"4,3156\",\"3,37426\"\n" 354 "\"4,3731\",\"3,45082\"\n" 355 "\"4,4305\",\"3,52738\"\n" 356 "\"4,4892\",\"3,60349\"\n" 357 "\"4,5486\",\"3,67938\"\n";
358 QString outputExpectedIfPeriodSeparator =
384 bool success = checkCommasInRelationsForDelimiter (EXPORT_DELIMITER_COMMA,
385 QLocale::Switzerland,
391 QVERIFY (outputGot == outputExpectedIfCommaSeparator ||
392 outputGot == outputExpectedIfPeriodSeparator);
395 void TestExport::testCommasInRelationsForCommasUnitedStates ()
397 QString outputExpected =
423 bool success = checkCommasInRelationsForDelimiter (EXPORT_DELIMITER_COMMA,
424 QLocale::UnitedStates,
430 QVERIFY (outputGot == outputExpected);
433 void TestExport::testCommasInRelationsForTabsSwitzerland ()
435 QString outputExpectedIfCommaSeparator =
459 QString outputExpectedIfPeriodSeparator =
485 bool success = checkCommasInRelationsForDelimiter (EXPORT_DELIMITER_TAB,
486 QLocale::Switzerland,
492 QVERIFY (outputGot == outputExpectedIfCommaSeparator ||
493 outputGot == outputExpectedIfPeriodSeparator);
496 void TestExport::testCommasInRelationsForTabsUnitedStates ()
498 QString outputExpected =
524 bool success = checkCommasInRelationsForDelimiter (EXPORT_DELIMITER_TAB,
525 QLocale::UnitedStates,
531 QVERIFY (outputGot == outputExpected);
534 void TestExport::testLogExtrapolationFunctionsAll ()
537 EXPORT_DELIMITER_COMMA,
538 QLocale::UnitedStates);
542 QTextStream str (&dummy);
547 unsigned int numWritesSoFar = 0;
550 exportFile.exportAllPerLineXThetaValuesMerged (m_modelExportOverride,
const CoordSystem & coordSystem() const
Currently active CoordSystem.
void setCursorSize(int cursorSize)
Set method for effective cursor size.
void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
void addPointGraphWithSpecifiedIdentifier(const QString &curveName, const QPointF &posScreen, const QString &identifier, double ordinal)
Add a single graph point with the specified point identifer. Note that PointStyle is not applied to t...
void setCoordScaleYRadius(CoordScale coordScale)
Set method for linear/log scale on y/radius.
void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
void setLocale(QLocale::Language language, QLocale::Country country)
Set method for locale given attributes.
Unit test of Export classes.
TestExport(QObject *parent=0)
Single constructor.
void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
Details for a specific Point.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void setModelCurveStyles(const CurveStyles &modelCurveStyles)
Set method for CurveStyles.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Container for LineStyle and PointStyle for one Curve.
Storage of one imported image and the data attached to that image.
Details for a specific Line.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void setExtraPrecision(int extraPrecision)
Set method for extra digits of precision.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void setCoordScaleXTheta(CoordScale coordScale)
Set method for linear/log scale on x/theta.
void setCoordsType(CoordsType coordsType)
Set method for coordinates type.