unit test
This commit is contained in:
@@ -61,4 +61,5 @@ test-suite haskell-math-test
|
||||
GF2test
|
||||
build-depends:
|
||||
base ^>=4.18.2.1,
|
||||
haskell-math
|
||||
haskell-math,
|
||||
HUnit
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
module GF2test (run) where
|
||||
|
||||
import Test.HUnit
|
||||
|
||||
import LinearAlgebra.GF2
|
||||
( fromBools
|
||||
, gaussianEliminationIndices
|
||||
@@ -12,18 +14,30 @@ run = do
|
||||
let rowsBools =
|
||||
[ [True, False, True]
|
||||
, [False, True, True]
|
||||
, [True, True, False]
|
||||
, [True, True, True]
|
||||
, [True, True, False]
|
||||
]
|
||||
|
||||
nCols = length (head rowsBools)
|
||||
rowsBits = map fromBools rowsBools
|
||||
|
||||
let maybeIndices = gaussianEliminationIndices nCols rowsBits
|
||||
maybeIndices = gaussianEliminationIndices nCols rowsBits
|
||||
|
||||
case maybeIndices of
|
||||
Nothing -> putStrLn "No combination found."
|
||||
Just idxs -> putStrLn $ "Rows: " ++ show idxs
|
||||
Nothing -> assertFailure "expected rows 0,1,3"
|
||||
Just rows -> assertEqual "expected rows 0,1,3" rows [0,1,3]
|
||||
|
||||
|
||||
-- no depency case
|
||||
let rowsBools2 =
|
||||
[ [True, False, True]
|
||||
, [False, True, True]
|
||||
, [True, True, True]
|
||||
]
|
||||
nCols2 = length (head rowsBools2)
|
||||
rowsBits2 = map fromBools rowsBools2
|
||||
maybeIndices2 = gaussianEliminationIndices nCols2 rowsBits2
|
||||
|
||||
assertEqual "Expected no dependency" Nothing maybeIndices2
|
||||
|
||||
putStrLn "GF2 Test Done."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user