[Kst] kdeextragear-2/kst/tests

George Staikos staikos at kde.org
Thu Nov 25 07:52:48 CET 2004


CVS commit by staikos: 

push coverage up to 51.8%, with 6 failures.  Still lots of untested code here,
and I'm not sure what to do about these failures.


  M +47 -0     testhistogram.cpp   1.4


--- kdeextragear-2/kst/tests/testhistogram.cpp  #1.3:1.4
@@ -68,4 +68,51 @@ void doTests() {
   //dumpPoints(h1, 11);
   doTest(count == 100); // should still account for the whole vector
+  h1->setNBins(9);
+  doTest(h1->nBins() == 9);
+  doTest(h1->vMin() == 0.0);
+  doTest(h1->vMax() == 10.0);
+  doTest(h1->vNumSamples() == 100);
+  for (int i = 1; i < 9*4; i += 3) {
+    double x, y;
+    h1->point(i, x, y);
+    count += int(y);
+  }
+  //dumpPoints(h1, 9);
+  doTest(count == 100); // should still account for the whole vector
+
+  // min > max
+  h1 = new KstHistogram("H2", vp, 10, 0, 10, KST_HS_NUMBER);
+  doTest(h1->type() == KST_HISTOGRAM);
+  doTest(h1->nBins() == 10);
+  doTest(h1->xMin() == 0.0);
+  doTest(h1->xMax() == 10.0);
+  doTest(h1->vMin() == 0.0);
+  doTest(h1->vMax() == 10.0);
+  doTest(h1->vNumSamples() == 100);
+  // min == max
+  h1 = new KstHistogram("H3", vp, 10, 10, 2, KST_HS_NUMBER);
+  doTest(h1->type() == KST_HISTOGRAM);
+  doTest(h1->nBins() == 2);
+  doTest(h1->xMin() == 9.0);
+  doTest(h1->xMax() == 11.0);
+  doTest(h1->vMin() == 0.0);
+  doTest(h1->vMax() == 10.0);
+  doTest(h1->vNumSamples() == 100);
+  // min-max < 2
+  h1 = new KstHistogram("H4", vp, 9, 10.999999, 1, KST_HS_NUMBER);
+  doTest(h1->type() == KST_HISTOGRAM);
+  doTest(h1->nBins() == 2);
+  doTest(h1->xMax() - h1->xMin() >= 2.0);
+  doTest(h1->vMin() == 0.0);
+  doTest(h1->vMax() == 10.0);
+  doTest(h1->vNumSamples() == 100);
+  h1->setXRange(10, 10);
+  doTest(h1->xMin() == 9.0);
+  doTest(h1->xMax() == 11.0);
+  h1->setXRange(9, 10.999999999);
+  doTest(h1->xMax() - h1->xMin() >= 2.0);
+  h1->setXRange(8, 10);
+  doTest(h1->xMin() == 9.0);
+  doTest(h1->xMax() == 10.0);
 }
 





More information about the Kst mailing list