module Math.CombinatoricsTest (combiTest) where

import Test.HUnit
import Data.Set (fromList)
import Math.Combinatorics


combiTest = TestLabel "Test set for combinatorics utilities." $ TestList [
        testSplitSum
    ]

testSplitSum = TestLabel "Test splitSum function" $ TestList [
        testNoTerms,
        testOneTerm,
        testTwoTerms,
        testThreeTerms
    ]

testNoTerms = TestCase $ [] @=? splitSum 0 13

testOneTerm = TestCase $ sequence_ $ map makeAssertion [1..10]
    where
    makeAssertion n = [[n]] @=? splitSum 1 n

testTwoTerms = TestCase $ sequence_ $ map (makeAssertions) [11..20]
    where
    makeAssertions :: Integer -> Assertion
    makeAssertions n = [[x, n-x] | x <- [0..n]] @=? splitSum 2 n

testThreeTerms = TestCase $ do
    [[0, 0, 1], [0, 1, 0], [1, 0, 0]] @=? splitSum 3 1
    fromList [[0, 0, 2], [0, 2, 0], [2, 0, 0],
        [0, 1, 1], [1, 0, 1], [1, 1, 0]] @=? (fromList $ splitSum 3 2)
