Commit 6fbf98f1 authored by Mathieu Giraud's avatar Mathieu Giraud

js/tools.js, tests: nice_min_max_step() yield no step when min = max

parent 7c7e3f84
......@@ -369,6 +369,9 @@ function nice_floor(x, force_pow10)
function nice_min_max_steps(min, max, nb_max_steps)
{
if (min == max)
return {min: min, max: max, step: 0, nb_steps: 0}
var basic_step = nice_1_2_5_ceil((max - min) / nb_max_steps)
var n_min = nice_floor(min, basic_step)
......
......@@ -72,6 +72,8 @@ QUnit.test("test nice_min_max_steps", function(assert) {
assert.deepEqual(nice_min_max_steps(43, 103, 5), {min: 40, max: 120, step: 20, nb_steps: 4}, "43..103 (5)");
assert.deepEqual(nice_min_max_steps(43, 103, 3), {min: 0, max: 150, step: 50, nb_steps: 3}, "43..103 (3)");
assert.deepEqual(nice_min_max_steps(42, 42, 20), {min: 42, max: 42, step: 0, nb_steps: 0}, "42..42 (20)");
});
QUnit.test("prepend_path_if_not_web", function(assert) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment