diff base/test/TestScaleTickIntervals.h @ 1461:45519a9836e6

Merge from branch horizontal-scale
author Chris Cannam
date Thu, 03 May 2018 15:24:06 +0100
parents 9528c73aa98c
children 2b2b58ae8b59
line wrap: on
line diff
--- a/base/test/TestScaleTickIntervals.h	Tue Apr 24 15:02:54 2018 +0100
+++ b/base/test/TestScaleTickIntervals.h	Thu May 03 15:24:06 2018 +0100
@@ -438,7 +438,7 @@
         // pathological range
         auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 });
         ScaleTickIntervals::Ticks expected {
-            { 0.0, "0" }
+            { 0.0, "0.0" }
         };
         compareTicks(ticks, expected);
     }
@@ -458,7 +458,7 @@
         // senseless input
         auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 });
         ScaleTickIntervals::Ticks expected {
-            { 0.0, "0" },
+            { 0.0, "0.0" },
         };
         compareTicks(ticks, expected);
     }
@@ -468,7 +468,7 @@
         // senseless input
         auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 });
         ScaleTickIntervals::Ticks expected {
-            { 0.0, "0" },
+            { 0.0, "0.0" },
         };
         compareTicks(ticks, expected);
     }
@@ -498,8 +498,8 @@
         auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 });
         ScaleTickIntervals::Ticks expected {
             { 1.0, "1.0" },
-            { pow(10.0, 0.5), "3.2" },
-            { 10.0, "10.0" },
+            { 3.2, "3.2" },
+            { 10.0, "10" },
         };
         compareTicks(ticks, expected);
     }
@@ -518,7 +518,7 @@
     {
         auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 });
         ScaleTickIntervals::Ticks expected {
-            { 1000, "1e+03" },
+            { 1000, "1000" },
             { 1e+06, "1e+06" },
             { 1e+09, "1e+09" },
             { 1e+12, "1e+12" },
@@ -528,26 +528,96 @@
         };
         compareTicks(ticks, expected, true);
     }
-    
+
     void log_0p465_778_10()
     {
         auto ticks = ScaleTickIntervals::logarithmic({ 0.465, 778.08, 10 });
         ScaleTickIntervals::Ticks expected {
-            { 0.5, "0.5" },
+            { 0.5, "0.50" },
             { 1, "1.0" },
             { 2, "2.0" },
             { 4, "4.0" },
             { 8, "8.0" },
-            { 16, "16.0" },
-            { 32, "32.0" },
-            { 64, "64.0" },
-            { 128, "128.0" },
-            { 256, "256.0" },
-            { 512, "512.0" },
+            { 16, "16" },
+            { 32, "32" },
+            { 64, "64" },
+            { 130, "130" },
+            { 260, "260" },
+            { 510, "510" },
         };
         compareTicks(ticks, expected);
     }
     
+    void log_1_10k_10()
+    {
+        auto ticks = ScaleTickIntervals::logarithmic({ 1.0, 10000.0, 10 });
+        ScaleTickIntervals::Ticks expected {
+            { 1.0, "1.0" },
+            { 2.5, "2.5" },
+            { 6.3, "6.3" },
+            { 16.0, "16" },
+            { 40.0, "40" },
+            { 100.0, "100" },
+            { 250.0, "250" },
+            { 630.0, "630" },
+            { 1600.0, "1600" },
+            { 4000.0, "4000" },
+            { 10000.0, "1e+04" },
+        };
+        compareTicks(ticks, expected, true);
+    }
+    
+    void log_80_10k_6()
+    {
+        auto ticks = ScaleTickIntervals::logarithmic({ 80.0, 10000.0, 6 });
+        ScaleTickIntervals::Ticks expected {
+            { 130, "130" },
+            { 260, "260" },
+            { 510, "510" },
+            { 1000, "1000" },
+            { 2000, "2000" },
+            { 4100, "4100" },
+            { 8200, "8200" }
+        };
+        compareTicks(ticks, expected, true);
+    }
+    
+    void log_80_800k_10()
+    {
+        auto ticks = ScaleTickIntervals::logarithmic({ 80.0, 800000.0, 10 });
+        ScaleTickIntervals::Ticks expected {
+            { 100, "100" },
+            { 250, "250" },
+            { 630, "630" },
+            { 1600, "1600" },
+            { 4000, "4000" },
+            { 10000, "1e+04" },
+            { 25000, "2.5e+04" },
+            { 63000, "6.3e+04" },
+            { 160000, "1.6e+05" },
+            { 400000, "4e+05" },
+        };
+        compareTicks(ticks, expected, true);
+    }
+    
+    void log_0_1_0()
+    {
+        // senseless input
+        auto ticks = ScaleTickIntervals::logarithmic({ 0, 1, 0 });
+        ScaleTickIntervals::Ticks expected {
+        };
+        compareTicks(ticks, expected);
+    }
+    
+    void log_0_1_m1()
+    {
+        // senseless input
+        auto ticks = ScaleTickIntervals::logarithmic({ 0, 1, -1 });
+        ScaleTickIntervals::Ticks expected {
+        };
+        compareTicks(ticks, expected);
+    }
+
 };
 
 #endif