use helper to shorten looseLabels tests

This commit is contained in:
Daniel Barlow 2024-11-17 09:40:54 +00:00
parent 40af75c140
commit aaaa0041d1

View File

@ -4,32 +4,19 @@ import Lib exposing (..)
import Test exposing (..)
import Expect exposing (Expectation)
specs: Test
specs =
describe "looseLabels"
[ test "0-100" <|
\_ ->
let (u, v, _) = looseLabels 10 0.0 100.0
in Expect.equal (0, 100) (u, v)
, test "2-98" <|
\_ ->
let (u, v, _) = looseLabels 10 2 98
in Expect.equal (0, 100) (u, v)
, test "8-91" <|
\_ ->
let (u, v, _) = looseLabels 10 8 91
in Expect.equal (0, 100) (u, v)
, test "1-32" <|
\_ ->
let (u, v, _) = looseLabels 8 1 32
in Expect.equal (0, 35) (u, v)
, test "1-36" <|
\_ ->
let (u, v, _) = looseLabels 8 1 36
in Expect.equal (0, 40) (u, v)
, test "1-4" <|
\_ ->
let (u, v, _) = looseLabels 10 1 4
in Expect.equal (1, 4) (u, v)
let runCheck ticks lower upper expected =
let label = (Debug.toString (lower, upper)) ++ " -> " ++ (Debug.toString expected)
in test label <| \_ ->
Expect.equal expected (looseLabels ticks lower upper)
in
describe "looseLabels"
[ runCheck 10 0 100 (0.0, 100.0, 10)
, runCheck 10 2 98 (0.0, 100.0, 10)
, runCheck 10 8 91 (0.0, 100.0, 10)
, runCheck 8 1 32 (0, 35, 5)
, runCheck 8 1 36 (0, 40, 5)
, runCheck 10 1 4 (1, 4, 0.5)
]