Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module BHeapSpec (spec) where
- import BinomialHeap as BHeap
- import Data.List as List
- import Test.HUnit
- import Test.QuickCheck
- testBHeapSortList :: [Int]
- testBHeapSortList = [4, 5, 2, 1, 3, 6, 3, 4]
- testBHeapSort = TestCase $ assertEqual "List after sort" (List.sort testBHeapSortList) (BHeap.binHeapSort testBHeapSortList)
- testlist = TestList [TestLabel "testBHeapSort" testBHeapSort]
- prop_elem :: Int -> [Int] -> Bool
- prop_elem x xs = elem x (BHeap.binHeapSort xs) == elem x xs
- prop_ordered :: [Int] -> Bool
- prop_ordered xs = ordered (BHeap.binHeapSort xs)
- where
- ordered (x:y:xs) = x <= y && ordered (y:xs)
- ordered _ = True
- prop_length :: [Int] -> Bool
- prop_length xs = length (BHeap.binHeapSort xs) == length xs
- spec :: IO ()
- spec = do
- quickCheck (withMaxSuccess 1000 prop_length)
- quickCheck (withMaxSuccess 1000 prop_ordered)
- quickCheck (withMaxSuccess 100000 prop_elem)
- runTestTT testlist
- return ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement