use partial functions in tests
I claim that it's ok because if the match is non-exhaustive then the test will fail anyway
This commit is contained in:
parent
aeb002092c
commit
31ba15f5a9
@ -69,32 +69,28 @@ testMalformed = TestCase $
|
||||
test2 = TestCase $
|
||||
either
|
||||
(assertFailure . displayException)
|
||||
(\ trk -> case trk of
|
||||
p:_ ->
|
||||
assertEqual "matches lat/lon"
|
||||
(Track.Pos 51.0 (-0.1))
|
||||
(Track.pos p)
|
||||
[] -> assertFailure "no points")
|
||||
(\ (p:_) ->
|
||||
assertEqual "matches lat/lon"
|
||||
(Track.Pos 51.0 (-0.1))
|
||||
(Track.pos p))
|
||||
(Track.parse onepoint)
|
||||
|
||||
test3 = TestCase $
|
||||
case Track.parse onepoint
|
||||
of
|
||||
Left err -> assertFailure (displayException err)
|
||||
Right (p:ps) ->
|
||||
assertEqual "matches attributes"
|
||||
(Nothing, Nothing) (Track.elevation p, Track.cadence p)
|
||||
Right [] -> assertFailure "no points"
|
||||
either
|
||||
(assertFailure . displayException)
|
||||
(\ (p:_) ->
|
||||
assertEqual "handles missing attributes"
|
||||
(Nothing, Nothing) (Track.elevation p, Track.cadence p))
|
||||
(Track.parse onepoint)
|
||||
|
||||
test4 = TestCase $
|
||||
case Track.parse onepointWithAttrs
|
||||
of
|
||||
Left err -> assertFailure (displayException err)
|
||||
Right (p:ps) ->
|
||||
assertEqual "matches attributes"
|
||||
either
|
||||
(assertFailure . displayException)
|
||||
(\ (p:_) ->
|
||||
assertEqual "handles attributes"
|
||||
(Just 25.2, Just 128, Just 55, Data.Time.UTCTime (toEnum 60606) 27299.779)
|
||||
(Track.elevation p, Track.cadence p, Track.power p, Track.time p)
|
||||
Right [] -> assertFailure "no points"
|
||||
(Track.elevation p, Track.cadence p, Track.power p, Track.time p))
|
||||
(Track.parse onepointWithAttrs)
|
||||
|
||||
tests :: Test
|
||||
tests = TestList [
|
||||
|
Loading…
Reference in New Issue
Block a user