[Kst] kdeextragear-2/kst/tests
George Staikos
staikos at kde.org
Mon Nov 22 19:40:47 CET 2004
CVS commit by staikos:
add a plugin test -> pushes coverage of the interpreter to ~90%, and basically
as far as I intend to go for now.
M +22 -4 testeqparser.cpp 1.7
--- kdeextragear-2/kst/tests/testeqparser.cpp #1.6:1.7
@@ -6,8 +6,9 @@
#include <assert.h>
#include <enodes.h>
+#include <kapplication.h>
#include <kstdatacollection.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-#include <math.h>
extern "C" int yyparse();
@@ -28,4 +29,5 @@ bool optimizerFailed = false;
KstVectorList vectorsUsed;
+KstVectorPtr xVector;
bool doTest(const char *equation, double x, double result, const double tol = 0.00000000001) {
@@ -41,4 +43,8 @@ bool doTest(const char *equation, double
ctx.noPoint = NOPOINT;
ctx.x = x;
+ ctx.xVector = xVector;
+ if (xVector) {
+ ctx.sampleCount = xVector->length();
+ }
Equation::FoldVisitor vis(&ctx, eq);
if (eq->isConst()) {
@@ -87,4 +93,5 @@ void testParseFail(const char *equation)
static void exitHelper() {
+ xVector = 0L;
vectorsUsed.clear();
KST::vectorList.clear();
@@ -93,9 +100,11 @@ static void exitHelper() {
-int main() {
+int main(int argc, char **argv) {
atexit(exitHelper);
- test("", 1.0, 0.0); // TODO: Should it pass? Currently gives parse error
+
+ KApplication app(argc, argv, "testeqparser", false, false);
// Base cases
+ test("", 1.0, 0.0); // TODO: Should it pass? Currently gives parse error
test("0", 1.0, 0.0);
test("1.0", 2.0, 1.0);
@@ -276,6 +285,15 @@ int main() {
KstVector::generateVector(-1.0, 1.0, 1000, "V4");
test("[V2] - [V1]", 0.0, 1.0);
+ // TODO: interpolation, more vector combinations
- // TODO: Plugins
+ // Plugins
+ test("2*plugin(bin, [V4], 12)", 1.0, -1.9779779779779778);
+ test("4*plugin(bin, [V4], x)", 5.0, -3.9839839839839839);
+ test("-3*plugin(bin, x, 12)", 2.0, NOPOINT);
+ xVector = KstVector::generateVector(0, 100, 2000, "XVector");
+ test("-3*plugin(bin, x, 12)", 2.0, -0.8254127063531767);
+ test("-3*plugin(bin, y, 12)", 2.0, NOPOINT);
+
+ // TODO: more plugin tests
// Errors:
More information about the Kst
mailing list