module PointTest exposing (specs) import Point exposing (Point, Pos, downsample) import Test exposing (..) import Expect exposing (Expectation) newPoint i = Point (1731437067 + (toFloat i)*1.2) (Pos 52 1 (Just 10)) (Just (round(sin((toFloat i)/10)*10))) (Just i) Nothing points n = List.map newPoint (List.range 0 n) maybe default val = case val of Just v -> v Nothing -> default specs: Test specs = describe "downsample" [ test "it returns no more points than requested" <| \_ -> let orig = (points 10) sampled = Point.downsample 5 orig in Expect.equal 5 (List.length sampled) , test "it drops points which are too close together" <| \_ -> let orig = List.map newPoint [ 0, 1, 2, 3, 4, 10, 500, 1000 ] sampled = Point.downsample 10 orig idx p = maybe 0 p.power in Expect.equalLists [0, 500, 1000] (List.map idx sampled) ]