implement first actual test case with hspec and run it

This commit is contained in:
Trolli Schmittlauch 2020-03-05 12:40:26 +01:00
parent 21fef145a0
commit 57e759836c
3 changed files with 11 additions and 3 deletions

View file

@ -1 +1 @@
(import ./. {}).shell (import ./default.nix {}).shell

View file

@ -11,6 +11,7 @@ Modernised EpiChord + k-choices load balancing
module Hash2Pub.FediChord ( module Hash2Pub.FediChord (
NodeID -- abstract, but newtype constructors cannot be hidden NodeID -- abstract, but newtype constructors cannot be hidden
, getNodeID
, mkNodeID , mkNodeID
, NodeState (..) , NodeState (..)
, CacheEntry , CacheEntry

View file

@ -1,6 +1,13 @@
module Main (main) where module Main (main) where
import qualified Hash2Pub.FediChord as FC import Test.Hspec
import Hash2Pub.FediChord
main :: IO () main :: IO ()
main = putStrLn "Test suite not yet implemented." main = hspec $ do
describe "NodeID" $ do
it "can store a numeral ID" $ do
getNodeID (mkNodeID 2342) `shouldBe` 2342
it "computes ID values within the modular bounds" $ do
getNodeID ((maxBound :: NodeID) + mkNodeID 2) < getNodeID (maxBound :: NodeID) `shouldBe` True