Add first unit tests
This commit is contained in:
parent
c3e61f6448
commit
323b75630d
3 changed files with 41 additions and 3 deletions
|
@ -34,9 +34,13 @@ executable orbit-exe
|
||||||
test-suite orbit-test
|
test-suite orbit-test
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
hs-source-dirs: test
|
hs-source-dirs: test
|
||||||
main-is: Spec.hs
|
main-is: Tests.hs
|
||||||
build-depends: base
|
build-depends: base
|
||||||
, orbit
|
, orbit
|
||||||
|
, linear
|
||||||
|
, tasty
|
||||||
|
, tasty-hunit
|
||||||
|
, tasty-quickcheck
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
main :: IO ()
|
|
||||||
main = putStrLn "Test suite not yet implemented"
|
|
36
test/Tests.hs
Normal file
36
test/Tests.hs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
module Main where
|
||||||
|
|
||||||
|
import Test.Tasty
|
||||||
|
import Test.Tasty.QuickCheck as QC
|
||||||
|
import Test.Tasty.HUnit
|
||||||
|
|
||||||
|
import Linear.Vector
|
||||||
|
import Linear.V3
|
||||||
|
import Linear.Affine
|
||||||
|
import Linear.Metric
|
||||||
|
|
||||||
|
import Lib
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
defaultMain (testGroup "Orbit tests" [unitTests, propertyChecks])
|
||||||
|
|
||||||
|
unitTests :: TestTree
|
||||||
|
unitTests = testGroup "Unit tests"
|
||||||
|
[ testCase "bodyDistance sun earth"
|
||||||
|
$ bodyDistance sun earth @?= astronomicalUnit
|
||||||
|
, testCase "bodyDistance earth moon"
|
||||||
|
$ bodyDistance earth moon @?= 384399e3
|
||||||
|
, testCase "selectOctant sun earth"
|
||||||
|
$ selectOctant (_bodyPosition sun) earth @?= SED
|
||||||
|
, testCase "subOctree for an Empty Region"
|
||||||
|
$ let r = Region (P $ V3 0 0 0) (P $ V3 0 0 0) 1 4
|
||||||
|
r' = Region (P $ V3 1 1 1) (P $ V3 0 0 0) 1 2
|
||||||
|
in
|
||||||
|
subOctree r NEU @?= Empty r'
|
||||||
|
]
|
||||||
|
|
||||||
|
propertyChecks :: TestTree
|
||||||
|
propertyChecks = testGroup "Property tests (QuickCheck)"
|
||||||
|
[
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue