fixed

Pure Haskell large fixed-width integers.
git clone git://git.ppad.tech/fixed.git
Log | Files | Refs | README | LICENSE

commit a93333c184f7bb05c04c21019f50523c8d858b87
parent 4bd7257ed88172aba89040d80ae96d3ad3f73e42
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 22 Jan 2025 16:22:53 +0400

test: quot_rem_r unit tests

Diffstat:
Mppad-fixed.cabal | 1+
Mtest/Main.hs | 29++++++++++++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/ppad-fixed.cabal b/ppad-fixed.cabal @@ -41,6 +41,7 @@ test-suite fixed-tests , bytestring , ppad-fixed , tasty + , tasty-hunit , tasty-quickcheck benchmark fixed-bench diff --git a/test/Main.hs b/test/Main.hs @@ -7,6 +7,7 @@ import Data.Bits ((.|.), (.&.), (.<<.), (.>>.)) import Data.Word (Word64) import Data.Word.Extended import Test.Tasty +import qualified Test.Tasty.HUnit as H import qualified Test.Tasty.QuickCheck as Q instance Q.Arbitrary Word256 where @@ -101,6 +102,18 @@ mul_512_matches (Q.NonNegative a) (Q.NonNegative b) = !rite = to_word512 (a * b) in left == rite +-- assertions ------------------------------------------------------------------ + +quot_rem_r_case0 :: H.Assertion +quot_rem_r_case0 = do + let !(P q r) = quot_rem_r 2 4 4 + H.assertEqual mempty (P 9223372036854775809 0) (P q r) + +quot_rem_r_case1 :: H.Assertion +quot_rem_r_case1 = do + let !(P q r) = quot_rem_r 0 4 2 + H.assertEqual mempty (P 2 0) (P q r) + -- main ----------------------------------------------------------------------- inverses :: TestTree @@ -134,10 +147,16 @@ utils = testGroup "utils" [ ] main :: IO () -main = defaultMain $ testGroup "ppad-fw" [ - utils - , inverses - , arithmetic +main = defaultMain $ + testGroup "ppad-fixed" [ + testGroup "property tests" [ + utils + , inverses + , arithmetic + ] + , testGroup "unit tests" [ + H.testCase "quot_rem_r matches case0" quot_rem_r_case0 + , H.testCase "quot_rem_r matches case1" quot_rem_r_case1 + ] ] -