implemented isValid
for Word16
This commit is contained in:
parent
af26fcedd8
commit
c494a25587
|
@ -47,7 +47,14 @@ instance Hamming Word16 where
|
|||
, ( 0x0001, 0xfffe )
|
||||
]
|
||||
|
||||
isValid = undefined
|
||||
isValid code = not $ any (\mask -> oddParity $ code .&. mask)
|
||||
[ 0xaaaa
|
||||
, 0xcccc
|
||||
, 0xf0f0
|
||||
, 0xff00
|
||||
, 0xffff
|
||||
]
|
||||
|
||||
correctErrors = undefined
|
||||
|
||||
setCheckBit :: (Num a, Bits a) => a -> (a, a) -> a
|
||||
|
|
|
@ -47,8 +47,18 @@ setCheckBitsSpec = describe "setCheckBits" $ mapM_
|
|||
]
|
||||
|
||||
isValidSpec :: Spec
|
||||
isValidSpec = describe "isValid" $
|
||||
return ()
|
||||
isValidSpec = describe "isValid" $ mapM_
|
||||
( \(desc, code, expected) -> context desc $ let
|
||||
actual = isValid code
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "all zeroes", 0, True )
|
||||
, ( "all ones", 0xffff, True )
|
||||
, ( "valid", withChkBits, True )
|
||||
, ( "no check bits", noChkBits, False )
|
||||
, ( "bad check bits", badChkBits, False )
|
||||
]
|
||||
|
||||
correctErrorsSpec :: Spec
|
||||
correctErrorsSpec = describe "correctErrors" $
|
||||
|
|
Loading…
Reference in New Issue
Block a user