implemented getNumBeads

This commit is contained in:
2024-08-20 20:41:28 -04:00
parent f43eb607ff
commit 9bd9b4a05e
2 changed files with 22 additions and 2 deletions

View File

@@ -21,14 +21,16 @@ License along with this program. If not, see
module AbacusSpec (spec) where
import Data.Maybe (fromJust)
import Test.Hspec (Spec, context, describe, it, shouldBe)
import Abacus
import Abacus.Internal
spec :: Spec
spec = describe "Abacus"
spec = describe "Abacus" $ do
newAbacusSpec
getNumBeadsSpec
newAbacusSpec :: Spec
newAbacusSpec = describe "newAbacusSpec" $ mapM_
@@ -42,4 +44,18 @@ newAbacusSpec = describe "newAbacusSpec" $ mapM_
, ( "no rungs", 10, 0, Nothing )
]
getNumBeadsSpec :: Spec
getNumBeadsSpec = describe "getNumBeads" $ mapM_
( \(desc, input, expected) -> context desc $ let
actual = getNumBeads input
in it ("should be " ++ show expected) $
actual `shouldBe` expected
)
[ ( "one bead", oneBead, 1 )
, ( "ten beads", tenBeads, 10 )
] where
oneBead = build 1
tenBeads = build 10
build n = fromJust $ newAbacus n 10
--jl