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 initializeLogging (
"engauge_test",
37 NO_GNUPLOT_LOG_FILES);
41 void TestProjectedPoint::testProjectedPoints ()
43 double radiusCircle = 1.0, radiusProjection = 2.0 * radiusCircle;
44 double xToProjectRight = radiusProjection, yToProjectRight = 0.0;
45 double xToProjectUp = 0.0, yToProjectUp = 2.0 * radiusCircle;
46 double xProjectionRight, yProjectionRight, projectedDistanceOutsideLineRight;
47 double xProjectionUp, yProjectionUp, projectedDistanceOutsideLineUp;
48 double distanceToLine;
55 int angleCriticalRight = (int) (0.5 + qAcos (radiusCircle / radiusProjection) * RADIANS_TO_DEGREES);
56 int angleCriticalUp = (int) (0.5 + qAsin (radiusCircle / radiusProjection) * RADIANS_TO_DEGREES);
58 for (
int angle = 0; angle <= 360; angle += angleStep) {
60 double xStart = radiusCircle * cos (angle * PI / 180.0);
61 double yStart = radiusCircle * sin (angle * PI / 180.0);
62 double xStop = -1.0 * xStart;
63 double yStop = -1.0 * yStart;
65 double xMin = qMin (xStart, xStop);
66 double yMin = qMin (yStart, yStop);
67 double xMax = qMax (xStart, xStop);
68 double yMax = qMax (yStart, yStop);
71 projectPointOntoLine (xToProjectRight,
79 &projectedDistanceOutsideLineRight,
84 if ((angleCriticalRight <= angle && angle <= 180 - angleCriticalRight) ||
85 (180 + angleCriticalRight <= angle && angle <= 360 - angleCriticalRight)) {
87 QVERIFY (projectedDistanceOutsideLineRight == 0);
89 QVERIFY (projectedDistanceOutsideLineRight != 0);
91 QVERIFY (xMin <= xProjectionRight);
92 QVERIFY (yMin <= yProjectionRight);
93 QVERIFY (xProjectionRight <= xMax);
94 QVERIFY (yProjectionRight <= yMax);
97 projectPointOntoLine (xToProjectUp,
105 &projectedDistanceOutsideLineUp,
110 if ((angle <= angleCriticalUp) ||
111 (180 - angleCriticalUp <= angle && angle <= 180 + angleCriticalUp) ||
112 (360 - angleCriticalUp <= angle)) {
114 QVERIFY (projectedDistanceOutsideLineUp == 0);
116 QVERIFY (projectedDistanceOutsideLineUp != 0);
118 QVERIFY (xMin <= xProjectionUp);
119 QVERIFY (yMin <= yProjectionUp);
120 QVERIFY (xProjectionUp <= xMax);
121 QVERIFY (yProjectionUp <= yMax);
Unit test of spline library.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...