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

@@ -61,4 +61,5 @@ test-suite haskell-math-test
GF2test GF2test
build-depends: build-depends:
base ^>=4.18.2.1, base ^>=4.18.2.1,
haskell-math haskell-math,
HUnit

View File

@@ -1,5 +1,7 @@
module GF2test (run) where module GF2test (run) where
import Test.HUnit
import LinearAlgebra.GF2 import LinearAlgebra.GF2
( fromBools ( fromBools
, gaussianEliminationIndices , gaussianEliminationIndices
@@ -12,18 +14,30 @@ run = do
let rowsBools = let rowsBools =
[ [True, False, True] [ [True, False, True]
, [False, True, True] , [False, True, True]
, [True, True, False]
, [True, True, True] , [True, True, True]
, [True, True, False]
] ]
nCols = length (head rowsBools) nCols = length (head rowsBools)
rowsBits = map fromBools rowsBools rowsBits = map fromBools rowsBools
maybeIndices = gaussianEliminationIndices nCols rowsBits
let maybeIndices = gaussianEliminationIndices nCols rowsBits
case maybeIndices of case maybeIndices of
Nothing -> putStrLn "No combination found." Nothing -> assertFailure "expected rows 0,1,3"
Just idxs -> putStrLn $ "Rows: " ++ show idxs 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." putStrLn "GF2 Test Done."