2 #include "MainWindow.h"
5 #include <QtTest/QtTest>
7 #include "SplinePair.h"
8 #include "Test/TestProjectedPoint.h"
14 const
double PI = 3.1415926535;
15 const
double RADIANS_TO_DEGREES = 180.0 / PI;
22 void TestProjectedPoint::cleanupTestCase ()
27 void TestProjectedPoint::initTestCase ()
29 const QString NO_ERROR_REPORT_LOG_FILE;
30 const bool NO_GNUPLOT_LOG_FILES =
false;
31 const bool DEBUG_FLAG =
false;
32 const QStringList NO_LOAD_STARTUP_FILES;
34 initializeLogging (
"engauge_test",
40 NO_LOAD_STARTUP_FILES);
44 void TestProjectedPoint::testProjectedPoints ()
46 double radiusCircle = 1.0, radiusProjection = 2.0 * radiusCircle;
47 double xToProjectRight = radiusProjection, yToProjectRight = 0.0;
48 double xToProjectUp = 0.0, yToProjectUp = 2.0 * radiusCircle;
49 double xProjectionRight, yProjectionRight, projectedDistanceOutsideLineRight;
50 double xProjectionUp, yProjectionUp, projectedDistanceOutsideLineUp;
51 double distanceToLine;
58 int angleCriticalRight = (int) (0.5 + qAcos (radiusCircle / radiusProjection) * RADIANS_TO_DEGREES);
59 int angleCriticalUp = (int) (0.5 + qAsin (radiusCircle / radiusProjection) * RADIANS_TO_DEGREES);
61 for (
int angle = 0; angle <= 360; angle += angleStep) {
63 double xStart = radiusCircle * cos (angle * PI / 180.0);
64 double yStart = radiusCircle * sin (angle * PI / 180.0);
65 double xStop = -1.0 * xStart;
66 double yStop = -1.0 * yStart;
68 double xMin = qMin (xStart, xStop);
69 double yMin = qMin (yStart, yStop);
70 double xMax = qMax (xStart, xStop);
71 double yMax = qMax (yStart, yStop);
74 projectPointOntoLine (xToProjectRight,
82 &projectedDistanceOutsideLineRight,
87 if ((angleCriticalRight <= angle && angle <= 180 - angleCriticalRight) ||
88 (180 + angleCriticalRight <= angle && angle <= 360 - angleCriticalRight)) {
90 QVERIFY (projectedDistanceOutsideLineRight == 0);
92 QVERIFY (projectedDistanceOutsideLineRight != 0);
94 QVERIFY (xMin <= xProjectionRight);
95 QVERIFY (yMin <= yProjectionRight);
96 QVERIFY (xProjectionRight <= xMax);
97 QVERIFY (yProjectionRight <= yMax);
100 projectPointOntoLine (xToProjectUp,
108 &projectedDistanceOutsideLineUp,
113 if ((angle <= angleCriticalUp) ||
114 (180 - angleCriticalUp <= angle && angle <= 180 + angleCriticalUp) ||
115 (360 - angleCriticalUp <= angle)) {
117 QVERIFY (projectedDistanceOutsideLineUp == 0);
119 QVERIFY (projectedDistanceOutsideLineUp != 0);
121 QVERIFY (xMin <= xProjectionUp);
122 QVERIFY (yMin <= yProjectionUp);
123 QVERIFY (xProjectionUp <= xMax);
124 QVERIFY (yProjectionUp <= yMax);
Unit test of spline library.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...