Created
February 2, 2010 21:14
-
-
Save anonymous/293031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Test.HUnit | |
import JoeBinarySearch | |
-- Note: | |
-- JoeBinarySearch.binary_search :: (Ord a) => [a] -> a -> Maybe Int | |
assertions = [ | |
([1], 1, (Just 0)), | |
([1, 3], 1, (Just 0)), | |
([1, 3, 4], 4, (Just 2)), | |
([1,2,4,6,8,9,12,15,17,20], 17, (Just 8)), | |
([1,2,4,6,8,9,12,15,17,20], 20, (Just 9)), | |
("hello", 'l', (Just 2)), | |
([0.0, 1.5, 3.0], 3.0, (Just 2)), | |
([], 1, Nothing), | |
([1,3], 2, Nothing), | |
([1,4,6,8,9,12,15,17,20], 2, Nothing), | |
([1,4,6,8,9,12,15,17,20], 100, Nothing), | |
([1,4,6,8,9,12,15,17,20], (-100), Nothing)] | |
test_list = TestList test_cases | |
where | |
test_cases = map test_func assertions | |
test_func (lst, input, expected) = TestCase $ assert_equal' ( binary_search lst input ) expected | |
assert_equal' = assertEqual "should equal" | |
main :: IO () | |
main = do | |
runTestTT test_list | |
print "DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment