From 68f20e7623909ae54f236a32b77d408ef4654138 Mon Sep 17 00:00:00 2001 From: Sam HADOW Date: Sun, 18 Jan 2026 15:27:07 +0100 Subject: [PATCH] unit test --- haskell-math.cabal | 3 ++- test/GF2test.hs | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/haskell-math.cabal b/haskell-math.cabal index 4f5798c..4188dfd 100644 --- a/haskell-math.cabal +++ b/haskell-math.cabal @@ -61,4 +61,5 @@ test-suite haskell-math-test GF2test build-depends: base ^>=4.18.2.1, - haskell-math + haskell-math, + HUnit diff --git a/test/GF2test.hs b/test/GF2test.hs index e95ebff..de4caf3 100644 --- a/test/GF2test.hs +++ b/test/GF2test.hs @@ -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."