souplesse

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

commit 0ad6eaec2f299a887cd343cf620de2579c5c8549
parent ed94fa57bc4f424a1a8b50ac98da2146f9a49b00
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 27 Oct 2024 23:13:39 +0000

test calls actual code we wrote

Diffstat:
Alib/Track.hs | 17+++++++++++++++++
Msouplesse.cabal | 12++++++++++++
Mtests/UnitTest.hs | 11+++++++++--
3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/lib/Track.hs b/lib/Track.hs @@ -0,0 +1,17 @@ +module Track where +import Data.Time +import qualified Data.List +data Pos = Pos Float Float + + +data Point = Point Pos UTCTime + +type Track = [Point] + +parse :: String -> Track +parse str = [ + -- Point (Pos 516 0) (UTCTime (toEnum 60631) 43200) + ] + +length :: Track -> Int +length trk = Data.List.length trk diff --git a/souplesse.cabal b/souplesse.cabal @@ -79,6 +79,17 @@ executable souplesse -- mostly copied from -- https://functional.works-hub.com/learn/basic-unit-testing-in-haskell-using-hunit-and-cabal-29e47 +library souplesse-lib + exposed-modules: + Track + hs-source-dirs: + lib + build-depends: + base >=4.7 && <5 + , HaXml + , time + default-language: GHC2021 + test-suite tests type: exitcode-stdio-1.0 main-is: UnitTest.hs @@ -86,5 +97,6 @@ test-suite tests tests build-depends: base >=4.7 && <5 + , souplesse-lib , HUnit default-language: GHC2021 diff --git a/tests/UnitTest.hs b/tests/UnitTest.hs @@ -1,10 +1,17 @@ module Main where --- import BasicSum + +import qualified Track (Track, parse, length ) import Test.HUnit import qualified System.Exit as Exit + test1 :: Test -test1 = TestCase (assertEqual "should return 3" 3 (1 + 2)) +test1 = TestCase $ + let + trk = Track.parse "<gpx></gpx>" + in + assertEqual "empty track has no elements" + 0 (Track.length trk) tests :: Test tests = TestList [TestLabel "test1" test1]