Permalink
Browse files

handle special case where min=max

plus tests
  • Loading branch information...
1 parent 810265a commit 160842a72daa83f3dba0cbaadb4281f9c35436d0 @mjdominus committed Nov 15, 2011
Showing with 15 additions and 1 deletion.
  1. +4 −0 spark
  2. +11 −1 spark-test.sh
View
4 spark
@@ -81,6 +81,10 @@ setup_array() {
range_n=$(( max_n * min_d - min_n * max_d ))
range_d=$(( max_d * min_d ))
+ if [[ $range_n = 0 ]] ; then
+ range_n=1
+ range_d=1
+ fi
numbers=($1)
}
View
@@ -63,4 +63,14 @@ it_zero_baseline() {
data='5,6,7'
test $(echo $data | $spark) = '▁▄▇'
test $(echo $data | $spark -z) = '▅▆▇'
-}
+}
+
+# tests for when min=max
+it_zero_range() {
+ test $($spark '1,1,1,1') = '▁▁▁▁'
+ test $($spark '53') = ''
+ test $($spark -z '1,1,1,1') = '▇▇▇▇'
+ test $($spark -z '53') = ''
+ test $($spark '0,0,0,0') = '▁▁▁▁'
+ test $($spark '0') = ''
+}

0 comments on commit 160842a

Please sign in to comment.