test cursor location
This commit is contained in:
parent
0c74a4ba61
commit
f949a65281
|
@ -21,8 +21,8 @@ License along with this program. If not, see
|
||||||
|
|
||||||
module Hamming.App.Widgets.InternalSpec (spec) where
|
module Hamming.App.Widgets.InternalSpec (spec) where
|
||||||
|
|
||||||
|
import Brick.Types (Location (..))
|
||||||
import Lens.Micro ((&), (.~))
|
import Lens.Micro ((&), (.~))
|
||||||
|
|
||||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||||
|
|
||||||
import Hamming.App
|
import Hamming.App
|
||||||
|
@ -35,11 +35,14 @@ spec = describe "Internal"
|
||||||
|
|
||||||
hammingW'Spec :: Spec
|
hammingW'Spec :: Spec
|
||||||
hammingW'Spec = describe "hammingW'" $ mapM_
|
hammingW'Spec = describe "hammingW'" $ mapM_
|
||||||
( \(desc, state, expRes) -> context desc $ do
|
( \(desc, state, expRes, expLoc) -> context desc $ do
|
||||||
let
|
let
|
||||||
(actRes, _) = hammingW' state
|
(actRes, actLoc) = hammingW' state
|
||||||
numActRows = length actRes
|
numActRows = length actRes
|
||||||
numExpRows = length expRes
|
numExpRows = length expRes
|
||||||
|
context "location" $
|
||||||
|
it ("should be " ++ show expLoc) $
|
||||||
|
actLoc `shouldBe` expLoc
|
||||||
context "number of rows" $
|
context "number of rows" $
|
||||||
it ("should be " ++ show numExpRows) $
|
it ("should be " ++ show numExpRows) $
|
||||||
numActRows `shouldBe` numExpRows
|
numActRows `shouldBe` numExpRows
|
||||||
|
@ -59,11 +62,14 @@ hammingW'Spec = describe "hammingW'" $ mapM_
|
||||||
) $ zip3 [(0 :: Int)..] actRow expRow
|
) $ zip3 [(0 :: Int)..] actRow expRow
|
||||||
) $ zip3 [(0 :: Int)..] actRes expRes
|
) $ zip3 [(0 :: Int)..] actRes expRes
|
||||||
)
|
)
|
||||||
[ ( "all zero", mkState 0, allZero )
|
[ ( "all zero", mkState 0, allZero, Nothing )
|
||||||
, ( "all one", mkState 0xffff, allOne )
|
, ( "all one", mkState 0xffff, allOne, Nothing )
|
||||||
, ( "arbitrary", mkState 0x3c5a, arbitrary )
|
, ( "arbitrary", mkState 0x3c5a, arbitrary, Nothing )
|
||||||
|
, ( "edit", es, allZero, Just eLoc )
|
||||||
] where
|
] where
|
||||||
mkState c = initialState & hammingCode .~ c
|
mkState c = initialState & hammingCode .~ c
|
||||||
|
es = mkState 0 & appMode .~ EditMode initialEditor
|
||||||
|
eLoc = Location (1, 1)
|
||||||
allZero =
|
allZero =
|
||||||
[ [ ( hammingAttr, ' ' )
|
[ [ ( hammingAttr, ' ' )
|
||||||
, ( marginAttr, '0' )
|
, ( marginAttr, '0' )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user