[Kst] branches/work/kst/portto4/kst/tests
George Staikos
staikos at kde.org
Mon Oct 1 21:07:06 CEST 2007
SVN commit 719712 by staikos:
Make these compile and restore unix line endings
M +1 -0 testcsd.cpp
M +1 -0 testdatasource.cpp
M +1 -0 testeditablematrix.cpp
M +8 -16 testeqparser.cpp
M +1 -0 testmatrix.cpp
M +5 -14 testscalar.cpp
--- branches/work/kst/portto4/kst/tests/testcsd.cpp #719711:719712
@@ -13,6 +13,7 @@
#include <QtTest>
+#include <kstmath.h>
#include <kstobject.h>
#include <qdir.h>
#include <qfile.h>
--- branches/work/kst/portto4/kst/tests/testdatasource.cpp #719711:719712
@@ -18,6 +18,7 @@
#include <QSettings>
#include <QTemporaryFile>
+#include <kstmath.h>
#include <kstrvector.h>
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
--- branches/work/kst/portto4/kst/tests/testeditablematrix.cpp #719711:719712
@@ -13,6 +13,7 @@
#include <QtTest>
+#include <kstmath.h>
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
#include <editablematrix.h>
--- branches/work/kst/portto4/kst/tests/testeqparser.cpp #719711:719712
@@ -13,6 +13,7 @@
#include <QtTest>
+#include <kstmath.h>
#include <enodes.h>
#include <eparse-eh.h>
@@ -29,17 +30,8 @@
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
-#ifdef NAN
double _NOPOINT = NAN;
-#else
-double _NOPOINT = 0.0/0.0; // NaN
-#endif
-#ifndef INFINITE
-double INFINITE = 1.0/0.0;
-#endif
-
-
void TestEqParser::cleanupTestCase() {
xVector = 0L;
vectorsUsed.clear();
@@ -119,7 +111,7 @@
eq->update(-1, &ctx);
double v = eq->value(&ctx);
delete eq;
- if (fabs(v - result) < tol || (result != result && v != v) || (result == INFINITE && v == INFINITE) || (result == -INFINITE && v == -INFINITE)) {
+ if (fabs(v - result) < tol || (result != result && v != v) || (result == INF && v == INF) || (result == -INF && v == -INF)) {
return true;
} else {
printf("Result: %.16f\n", v);
@@ -231,8 +223,8 @@
QVERIFY(validateEquation("abs(x)", 1.0, 1.0));
QVERIFY(validateEquation("abs(x)", -1.0, 1.0));
QVERIFY(validateEquation("abs(x)", _NOPOINT, _NOPOINT));
- QVERIFY(validateEquation("abs(x)", INFINITE, INFINITE));
- QVERIFY(validateEquation("abs(x)", -INFINITE, INFINITE));
+ QVERIFY(validateEquation("abs(x)", INF, INF));
+ QVERIFY(validateEquation("abs(x)", -INF, INF));
QVERIFY(validateEquation("abs(-0.000000000001)", 0.0, 0.000000000001));
QVERIFY(validateEquation("cos(acos(x))", 0.3875823288, 0.3875823288, 0.0000000001));
@@ -275,7 +267,7 @@
QVERIFY(validateEquation("0.0<=1.0", 0.0, 1.0));
QVERIFY(validateEquation("(0.0/0.0)==(0.0/0.0)", 0.0, 0.0));
QVERIFY(validateEquation("(0.0/0.0)==(1.0/0.0)", 0.0, 0.0));
- QVERIFY(validateEquation("(1.0/0.0)==(1.0/0.0)", 0.0, 1.0)); // INFINITE == INFINITE
+ QVERIFY(validateEquation("(1.0/0.0)==(1.0/0.0)", 0.0, 1.0)); // INF == INF
QVERIFY(validateEquation("(1.0/0.0)==-(1.0/0.0)", 0.0, 0.0));
QVERIFY(validateEquation("(0.0/0.0)==-(1.0/0.0)", 0.0, 0.0));
QVERIFY(validateEquation("(1.0/0.0)==(0.0/0.0)", 0.0, 0.0));
@@ -309,7 +301,7 @@
QVERIFY(validateEquation("!1.0", 0.0, 0.0));
QVERIFY(validateEquation("!-1.0", 0.0, 0.0));
QVERIFY(validateEquation("!2.0", 0.0, 0.0));
- QVERIFY(validateEquation("!x", INFINITE, 0.0));
+ QVERIFY(validateEquation("!x", INF, 0.0));
QVERIFY(validateEquation("!x", _NOPOINT, 1.0));
QVERIFY(validateEquation("!(1 > 2)", 0.0, 1.0));
QVERIFY(validateEquation("!1.0 > -1.0", 0.0, 1.0)); // (!1.0) > -1.0
@@ -334,8 +326,8 @@
new KstScalar(KstObjectTag::fromString("test2"), 0L, 0.0, true);
new KstScalar(KstObjectTag::fromString("test3"), 0L, -1.0, true);
new KstScalar(KstObjectTag::fromString("test4"), 0L, _NOPOINT, true);
- new KstScalar(KstObjectTag::fromString("test5"), 0L, INFINITE, true);
- new KstScalar(KstObjectTag::fromString("test6"), 0L, -INFINITE, true);
+ new KstScalar(KstObjectTag::fromString("test5"), 0L, INF, true);
+ new KstScalar(KstObjectTag::fromString("test6"), 0L, -INF, true);
QVERIFY(validateEquation("[test1]", 0.0, 1.0));
QVERIFY(validateEquation("[test4]", 0.0, _NOPOINT));
--- branches/work/kst/portto4/kst/tests/testmatrix.cpp #719711:719712
@@ -13,6 +13,7 @@
#include <QtTest>
+#include <kstmath.h>
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
--- branches/work/kst/portto4/kst/tests/testscalar.cpp #719711:719712
@@ -15,22 +15,13 @@
#include <QDomDocument>
+#include <kstmath.h>
#include <kstscalar.h>
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
-#include <math.h>
-
-#ifdef NAN
double NOPOINT = NAN;
-#else
-double NOPOINT = 0.0/0.0; // NaN
-#endif
-#ifndef INF
-double _INF = 1.0/0.0;
-#endif
-
SListener::SListener() : QObject(), _trigger(0) {}
SListener::~SListener() {}
void SListener::trigger() { _trigger++; }
@@ -82,9 +73,9 @@
QCOMPARE(sp->value(), 2.1415);
sp->setValue(NOPOINT);
QVERIFY(sp->value() != sp->value());
- sp->setValue(_INF );
+ sp->setValue(INF );
- QVERIFY(sp->value() == _INF);
+ QVERIFY(sp->value() == INF);
QCOMPARE((*sp = 2.0).value(), 2.0);
SListener *listener = new SListener;
@@ -128,13 +119,13 @@
e = n.toElement();
sp4 = new KstScalar(e);
- QVERIFY(sp4->value() == _INF);
+ QVERIFY(sp4->value() == INF);
n = makeDOMDocument("load4", "-INF").firstChild();
e = n.toElement();
sp4 = new KstScalar(e);
- QVERIFY(sp4->value() == -_INF);
+ QVERIFY(sp4->value() == -INF);
delete listener;
}
More information about the Kst
mailing list