souplesse

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 31ba15f5a93e8bb34a0075ef60cde80941622fed
parent aeb002092c9beeec1e986b0de262a03718e01028
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 30 Oct 2024 20:56:52 +0000

use partial functions in tests

I claim that it's ok because if the match is non-exhaustive then the
test will fail anyway

Diffstat:
Mtests/UnitTest.hs | 36++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/tests/UnitTest.hs b/tests/UnitTest.hs @@ -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 [