unit test

This commit is contained in:
2026-01-18 15:27:07 +01:00
parent f5d33ee418
commit 68f20e7623
2 changed files with 21 additions and 6 deletions

View File

@@ -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."