Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module BTreeSpec (spec) where
- import BinomialTree as BTree
- import Test.HUnit
- key :: Int
- key = 5
- rank :: Int
- rank = 2
- testTreeCreationTree :: BTree.BinTree Int
- testTreeCreationTree = BTree.createTree BTreeSpec.key BTreeSpec.rank []
- testTreeCreationKey = TestCase $ assertEqual ("Key of createTree " ++ show BTreeSpec.key ++ " _ _") BTreeSpec.key (BTree.key testTreeCreationTree)
- testTreeCreationRank = TestCase $ assertEqual ("Rank of createTree " ++ show BTreeSpec.rank ++ " _ _") BTreeSpec.rank (BTree.rank testTreeCreationTree)
- key1 :: Int
- key1 = 5
- key2 :: Int
- key2 = 10
- testTreeMerge1Tree :: BTree.BinTree Int
- testTreeMerge1Tree = BTree.createTree key1 1 []
- testTreeMerge2Tree :: BTree.BinTree Int
- testTreeMerge2Tree = BTree.createTree key2 1 []
- testTreeMergeKey1 = TestCase $ assertEqual "Key of root after merge" key1 (BTree.key (BTree.mergeTrees testTreeMerge1Tree testTreeMerge2Tree))
- testTreeMergeKey2 = TestCase $ assertEqual "Key of root after merge" key1 (BTree.key (BTree.mergeTrees testTreeMerge2Tree testTreeMerge1Tree))
- testTreeMergeRank = TestCase $ assertEqual "Key of root after merge" 2 (BTree.rank (BTree.mergeTrees testTreeMerge2Tree testTreeMerge1Tree))
- testTreeMergeChildren = TestCase $ assertEqual "Key of root after merge" [testTreeMerge2Tree] (BTree.children (BTree.mergeTrees testTreeMerge2Tree testTreeMerge1Tree))
- testlist = TestList [TestLabel "testTreeCreation" testTreeCreationKey,
- TestLabel "testTreeCreation" testTreeCreationRank,
- TestLabel "testTreeMerge" testTreeMergeKey1,
- TestLabel "testTreeMerge" testTreeMergeKey2,
- TestLabel "testTreeMerge" testTreeMergeRank,
- TestLabel "testTreeMerge" testTreeMergeChildren]
- spec :: IO ()
- spec = do
- runTestTT testlist
- return ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement