diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-23 14:51:38 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-23 14:51:38 +0100 |
commit | d1d28b9349549297f89ade80616eb7b14083e600 (patch) | |
tree | 7736e7d00ce1368cd70ed2a7c0bd6d27d957eb2e /tests/Hakyll/Core | |
parent | eabc26812d5deb6ef818c20b2ed4c4d07e14feaa (diff) | |
download | hakyll-d1d28b9349549297f89ade80616eb7b14083e600.tar.gz |
Add tests for the directed graph modules
Diffstat (limited to 'tests/Hakyll/Core')
-rw-r--r-- | tests/Hakyll/Core/DirectedGraph/Tests.hs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/DirectedGraph/Tests.hs b/tests/Hakyll/Core/DirectedGraph/Tests.hs new file mode 100644 index 0000000..4ce5944 --- /dev/null +++ b/tests/Hakyll/Core/DirectedGraph/Tests.hs @@ -0,0 +1,48 @@ +module Hakyll.Core.DirectedGraph.Tests + ( tests + ) where + +import Data.Set (Set) +import qualified Data.Set as S + +import Test.Framework +import Test.Framework.Providers.HUnit +import Test.HUnit hiding (Test) + +import Hakyll.Core.DirectedGraph +import Hakyll.Core.DirectedGraph.DependencySolver +import Hakyll.Core.DirectedGraph.ObsoleteFilter + +tests :: [Test] +tests = + [ testCase "solveDependencies01" solveDependencies01 + , testCase "filterObsolete01" filterObsolete01 + , testCase "filterObsolete02" filterObsolete02 + ] + +node :: Ord a => a -> [a] -> (a, Set a) +node t n = (t, S.fromList n) + +testGraph01 :: DirectedGraph Int +testGraph01 = fromList + [ node 8 [2, 4, 6] + , node 2 [4, 3] + , node 4 [3] + , node 6 [4] + , node 3 [] + ] + +solveDependencies01 :: Assertion +solveDependencies01 = result == [3, 4, 2, 6, 8] || result == [3, 4, 2, 6, 8] + @? "solveDependencies01" + where + result = solveDependencies testGraph01 + +filterObsolete01 :: Assertion +filterObsolete01 = nodes (filterObsolete [6] testGraph01) == S.fromList [6, 8] + @? "filterObsolete01" + +filterObsolete02 :: Assertion +filterObsolete02 = + nodes (filterObsolete [4] testGraph01) == S.fromList [4, 2, 6, 8] + @? "filterObsolete02" |