diff --git a/lib/Track.hs b/lib/Track.hs new file mode 100644 index 0000000..1480818 --- /dev/null +++ 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 index f11dbb9..61db521 100644 --- 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 index adb9930..8033537 100644 --- 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 "" + in + assertEqual "empty track has no elements" + 0 (Track.length trk) tests :: Test tests = TestList [TestLabel "test1" test1]