Permalink
Browse files

Add test for nextHighestPowerOfTwo

  • Loading branch information...
1 parent 6e8054d commit 3926e8a31488b9aa51c15a4b3eda37bc8a1ba64f @Shimuuar Shimuuar committed Nov 28, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 tests/Tests/Function.hs
View
@@ -7,13 +7,15 @@ import Test.QuickCheck
import Test.Framework
import Test.Framework.Providers.QuickCheck2
+import Tests.Helpers
import Statistics.Function
tests :: Test
tests = testGroup "S.Function"
- [ testProperty "Sort is sort" p_sort
+ [ testProperty "Sort is sort" p_sort
+ , testAssertion "nextHighestPowerOfTwo is OK" p_nextHighestPowerOfTwo
]
@@ -23,4 +25,9 @@ p_sort xs =
where
v = sort $ U.fromList xs
-
+p_nextHighestPowerOfTwo :: Bool
+p_nextHighestPowerOfTwo
+ = all (\(good, is) -> all ((==good) . nextHighestPowerOfTwo) is) lists
+ where
+ pows = [1 .. 17]
+ lists = [ (2^m, [2^n+1 .. 2^m]) | (n,m) <- pows `zip` tail pows ]

0 comments on commit 3926e8a

Please sign in to comment.