changeset 1410:c4af57d59434 scale-ticks

These tests now pass (in some cases by fixing the tests)
author Chris Cannam
date Wed, 03 May 2017 18:06:48 +0100
parents 21ba60008200
children 1f0d071e7ce6
files base/ScaleTickIntervals.h base/test/TestScaleTickIntervals.h
diffstat 2 files changed, 25 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/base/ScaleTickIntervals.h	Wed May 03 18:01:25 2017 +0100
+++ b/base/ScaleTickIntervals.h	Wed May 03 18:06:48 2017 +0100
@@ -84,9 +84,10 @@
         int prec = 1;
         
         if (fixed) {
-            prec = precInc;
-            if (prec < 0) {
-                prec = -prec;
+            if (precInc < 0) {
+                prec = -precInc;
+            } else if (precInc > 0) {
+                prec = 0;
             }
         } else {
             prec = precRange;
--- a/base/test/TestScaleTickIntervals.h	Wed May 03 18:01:25 2017 +0100
+++ b/base/test/TestScaleTickIntervals.h	Wed May 03 18:06:48 2017 +0100
@@ -87,13 +87,16 @@
     void linear_0_5_5()
     {
 	auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 });
+        // generally if we have some activity in the units column, we
+        // should add .0 to satisfy the human worry that we aren't
+        // being told the whole story...
 	vector<ScaleTickIntervals::Tick> expected {
-	    { 0, "0" },
-	    { 1, "1" },
-	    { 2, "2" },
-	    { 3, "3" },
-	    { 4, "4" },
-	    { 5, "5" },
+	    { 0, "0.0" },
+	    { 1, "1.0" },
+	    { 2, "2.0" },
+	    { 3, "3.0" },
+	    { 4, "4.0" },
+	    { 5, "5.0" },
 	};
 	compareTicks(ticks.ticks, expected);
     }
@@ -102,12 +105,12 @@
     {
 	auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 });
 	vector<ScaleTickIntervals::Tick> expected {
-	    { 0, "0" },
-	    { 2, "2" },
-	    { 4, "4" },
-	    { 6, "6" },
-	    { 8, "8" },
-	    { 10, "10" }
+	    { 0, "0.0" },
+	    { 2, "2.0" },
+	    { 4, "4.0" },
+	    { 6, "6.0" },
+	    { 8, "8.0" },
+	    { 10, "10.0" }
 	};
 	compareTicks(ticks.ticks, expected);
     }
@@ -186,12 +189,12 @@
     {
 	auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 });
 	vector<ScaleTickIntervals::Tick> expected {
-	    { 10000, "10000" },
-	    { 10002, "10002" },
-	    { 10004, "10004" },
-	    { 10006, "10006" },
-	    { 10008, "10008" },
-	    { 10010, "10010" },
+	    { 10000, "10000.0" },
+	    { 10002, "10002.0" },
+	    { 10004, "10004.0" },
+	    { 10006, "10006.0" },
+	    { 10008, "10008.0" },
+	    { 10010, "10010.0" },
 	};
 	compareTicks(ticks.ticks, expected);
     }