JAL-3206 avoid divide by zero when threshold is graphMin / graphMax
[jalview.git] / test / jalview / schemes / AnnotationColourGradientTest.java
index b7a5164..be8b58d 100644 (file)
@@ -124,6 +124,18 @@ public class AnnotationColourGradientTest
       Color result = testee.shadeCalculation(ann, col);
       assertEquals(result, expected, "for column " + col);
     }
+
+    /*
+     * test for boundary case threshold == graphMax (JAL-3206)
+     */
+    float thresh = ann.threshold.value;
+    ann.threshold.value = ann.graphMax;
+    Color result = testee.shadeCalculation(ann, WIDTH - 1);
+    assertEquals(result, maxColour);
+    testee.setThresholdIsMinMax(false);
+    result = testee.shadeCalculation(ann, WIDTH - 1);
+    assertEquals(result, maxColour);
+    ann.threshold.value = thresh; // reset
   }
 
   /**
@@ -174,6 +186,18 @@ public class AnnotationColourGradientTest
       Color result = testee.shadeCalculation(ann, col);
       assertEquals(result, expected, "for column " + col);
     }
+
+    /*
+     * test for boundary case threshold == graphMin (JAL-3206)
+     */
+    float thresh = ann.threshold.value;
+    ann.threshold.value = ann.graphMin;
+    Color result = testee.shadeCalculation(ann, 0);
+    assertEquals(result, minColour);
+    testee.setThresholdIsMinMax(false);
+    result = testee.shadeCalculation(ann, 0);
+    assertEquals(result, minColour);
+    ann.threshold.value = thresh; // reset
   }
 
   /**