[Kst] kdeextragear-2/kst/tests

George Staikos staikos at kde.org
Thu Nov 25 00:05:52 CET 2004


CVS commit by staikos: 

added a template for testcases along with a header file and ported eqparser
tests to use it


  A            ksttestcase.h   1.1 [UNKNOWN]
  A            testtemplate.cpp   1.1 [UNKNOWN]
  M +6 -19     testeqparser.cpp   1.13


--- kdeextragear-2/kst/tests/testeqparser.cpp  #1.12:1.13
@@ -4,11 +4,6 @@
  */
 
-#include <assert.h>
+#include "ksttestcase.h"
 #include <enodes.h>
-#include <kapplication.h>
-#include <kstdatacollection.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
 
 extern "C" int yyparse();
@@ -16,14 +11,4 @@ extern "C" void *ParsedEquation;
 extern "C" struct yy_buffer_state *yy_scan_string(const char*);
 
-#ifdef NAN
-double NOPOINT = NAN;
-#else
-double NOPOINT = 0.0/0.0; // NaN
-#endif
-
-#ifndef INF
-double INF = 1.0/0.0;
-#endif
-
 bool optimizerFailed = false;
 
@@ -31,4 +16,6 @@ KstVectorList vectorsUsed;
 KstVectorPtr xVector;
 
+int rc = KstTestSuccess;
+
 bool doTest(const char *equation, double x, double result, const double tol = 0.00000000001) {
         yy_scan_string(equation);
@@ -77,6 +64,6 @@ bool doTest(const char *equation, double
 void test(const char *equation, double x, double result, const double tol = 0.00000000001) {
         if (!doTest(equation, x, result, tol)) {
+                rc = KstTestFailure;
                 printf("Test of (%s)[%.16f] == %.16f failed.\n", equation, x, result);
-                //exit(-1);
         }
 }
@@ -87,5 +74,5 @@ void testParseFail(const char *equation)
         if (0 == yyparse()) {
                 printf("Test of (%s) parsing passed, but should have failed.\n", equation);
-                //exit(-1);
+                rc = KstTestFailure;
         }
 }
@@ -310,5 +297,5 @@ int main(int argc, char **argv) {
         testParseFail("foo(4, [])");
 
-        return 0;
+        return rc;
 }
 





More information about the Kst mailing list