test calls actual code we wrote
This commit is contained in:
parent
ed94fa57bc
commit
0ad6eaec2f
17
lib/Track.hs
Normal file
17
lib/Track.hs
Normal file
@ -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
|
@ -79,6 +79,17 @@ executable souplesse
|
|||||||
-- mostly copied from
|
-- mostly copied from
|
||||||
-- https://functional.works-hub.com/learn/basic-unit-testing-in-haskell-using-hunit-and-cabal-29e47
|
-- 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
|
test-suite tests
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: UnitTest.hs
|
main-is: UnitTest.hs
|
||||||
@ -86,5 +97,6 @@ test-suite tests
|
|||||||
tests
|
tests
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
|
, souplesse-lib
|
||||||
, HUnit
|
, HUnit
|
||||||
default-language: GHC2021
|
default-language: GHC2021
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
module Main where
|
module Main where
|
||||||
-- import BasicSum
|
|
||||||
|
import qualified Track (Track, parse, length )
|
||||||
import Test.HUnit
|
import Test.HUnit
|
||||||
import qualified System.Exit as Exit
|
import qualified System.Exit as Exit
|
||||||
|
|
||||||
|
|
||||||
test1 :: Test
|
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 :: Test
|
||||||
tests = TestList [TestLabel "test1" test1]
|
tests = TestList [TestLabel "test1" test1]
|
||||||
|
Loading…
Reference in New Issue
Block a user