4 #include <QtTest/QtTest>
18 void TestExportAlign::cleanupTestCase ()
22 bool TestExportAlign::epsilonTest (
double a,
25 double epsilon = qMax (qAbs (a), qAbs (b)) / 100000.0;
30 return qAbs (a - b) <= epsilon;
33 void TestExportAlign::initTestCase ()
40 void TestExportAlign::testLinearDigits1 ()
42 QVERIFY (testLinearGeneric (4, 6) == 4);
45 void TestExportAlign::testLinearDigits2 ()
47 QVERIFY (testLinearGeneric (4.4, 4.6) == 4.4);
50 void TestExportAlign::testLinearDigits3 ()
52 QVERIFY (testLinearGeneric (4.44, 4.46) == 4.44);
55 double TestExportAlign::testLinearGeneric (
double xMin,
59 return align.firstSimplestNumber ();
62 void TestExportAlign::testLinearHighDynamicRangeNegNeg ()
64 QVERIFY (testLinearGeneric (-4.3, -0.002) == -5.0);
67 void TestExportAlign::testLinearHighDynamicRangeNegPos ()
69 QVERIFY (testLinearGeneric (-0.002, 4.3) == -1.0);
72 void TestExportAlign::testLinearHighDynamicRangePosPos ()
74 QVERIFY (testLinearGeneric (0.002, 4.3) == 0.0);
77 void TestExportAlign::testLinearLowDynamicRangeNegNeg ()
79 QVERIFY (testLinearGeneric (-4.3, -0.2) == -5.0);
82 void TestExportAlign::testLinearLowDynamicRangeNegPos ()
84 QVERIFY (testLinearGeneric (-4.3, 0.2) == -5.0);
87 void TestExportAlign::testLinearLowDynamicRangePosPos ()
89 QVERIFY (testLinearGeneric (0.2, 4.3) == 0.0);
92 void TestExportAlign::testLinearRelativelySmallRangeNeg ()
94 QVERIFY (testLinearGeneric (-4.9995, -4.9993) == -4.9995);
97 void TestExportAlign::testLinearRelativelySmallRangePos ()
99 QVERIFY (testLinearGeneric (4.9993, 4.9995) == 4.9993);
102 void TestExportAlign::testLogDigits1 ()
104 QVERIFY (epsilonTest (testLogGeneric (4, 6), 4));
107 void TestExportAlign::testLogDigits2 ()
109 QVERIFY (epsilonTest (testLogGeneric (4.4, 4.6), 4.4));
112 void TestExportAlign::testLogDigits3 ()
114 QVERIFY (epsilonTest (testLogGeneric (4.44, 4.46), 4.44));
117 double TestExportAlign::testLogGeneric (
double xMinExponent,
118 double xMaxExponent)
const
120 double xMin = qPow (10.0, xMinExponent);
121 double xMax = qPow (10.0, xMaxExponent);
124 double result = align.firstSimplestNumber ();
125 double resultExponent = qLn (result) / qLn (10.0);
127 return resultExponent;
130 void TestExportAlign::testLogHighDynamicRangeNegNeg ()
132 QVERIFY (epsilonTest (testLogGeneric (-4.3, -0.002), -5.0));
135 void TestExportAlign::testLogHighDynamicRangeNegPos ()
137 QVERIFY (epsilonTest (testLogGeneric (-0.002, 4.3), -1.0));
140 void TestExportAlign::testLogHighDynamicRangePosPos ()
142 QVERIFY (epsilonTest (testLogGeneric (0.002, 4.3), 0.0));
145 void TestExportAlign::testLogLowDynamicRangeNegNeg ()
147 QVERIFY (epsilonTest (testLogGeneric (-4.3, -0.2), -5.0));
150 void TestExportAlign::testLogLowDynamicRangeNegPos ()
152 QVERIFY (epsilonTest (testLogGeneric (-4.3, 0.2), -5.0));
155 void TestExportAlign::testLogLowDynamicRangePosPos ()
157 QVERIFY (epsilonTest (testLogGeneric (0.2, 4.3), 0.0));
160 void TestExportAlign::testLogRelativelySmallRangeNeg ()
162 QVERIFY (epsilonTest (testLogGeneric (-4.9995, -4.9993), -4.9995));
165 void TestExportAlign::testLogRelativelySmallRangePos ()
167 QVERIFY (epsilonTest (testLogGeneric (4.9993, 4.9995), 4.9993));
Pick first simplest x value between specified min and max, for linear scaling.
Pick first simplest x value between specified min and max, for log scaling.
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
Unit test of ExportAlign classes.