@@ -1,4 +1,5 @@
1{-# LANGUAGE ViewPatterns #-}
1{-# LANGUAGE ViewPatterns #-}
2import qualified Data.ByteString.Lazy as BL
3import qualified Data.ByteString.Lazy as BL
3import qualified Data.ByteString.Lazy.Char8 as BL8
4import qualified Data.ByteString.Lazy.Char8 as BL8
4import qualified Data.ByteString.Char8 as BC8
5import qualified Data.ByteString.Char8 as BC8
@@ -8,51 +9,52 @@ import Data.Word
8import qualified Data.UUID.Types as U
9import qualified Data.UUID.Types as U
9import Foreign (alloca, peek, poke)
10import Foreign (alloca, peek, poke)
10import System.IO.Unsafe (unsafePerformIO)
11import System.IO.Unsafe (unsafePerformIO)
11−import qualified Test.HUnit as H
12+
12−import Test.HUnit hiding (Test)
13+import Test.QuickCheck ( Arbitrary(arbitrary), choose )
13−import Test.QuickCheck hiding ((.&.))
14+
14−import Test.Framework (defaultMain, Test)
15+import Test.Tasty ( defaultMain, TestTree, testGroup )
15−import Test.Framework.Providers.HUnit (hUnitTestToTests)
16+import Test.Tasty.HUnit ( assertBool, (@?=), (@=?), testCase )
16−import Test.Framework.Providers.QuickCheck2 (testProperty)
17+import Test.Tasty.QuickCheck ( testProperty )
19instance Arbitrary U.UUID where
20instance Arbitrary U.UUID where
20 -- the UUID random instance ignores bounds
21 -- the UUID random instance ignores bounds
21 arbitrary = choose (U.nil, U.nil)
22 arbitrary = choose (U.nil, U.nil)
24−test_null :: H.Test
26+test_null :: Test
25−test_null = H.TestList [
27+test_null =
28+ testCase "nil is null" $
26− "nil is null" ~: assertBool "" (U.null U.nil)
29+ assertBool "" (U.null U.nil)
29−test_nil :: H.Test
31+test_nil :: Test
30−test_nil = H.TestList [
32+test_nil = testGroup "nil" [
31− "nil string" ~: U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",
33+ testCase "nil string" $ U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",
32− "nil bytes" ~: U.toByteString U.nil @?= BL.pack (replicate 16 0)
34+ testCase "nil bytes" $ U.toByteString U.nil @?= BL.pack (replicate 16 0)
35−test_conv :: H.Test
37+test_conv :: Test
36−test_conv = H.TestList [
38+test_conv = testGroup "conversions" [
37− "conv bytes to string" ~:
39+ testCase "conv bytes to string" $
38 maybe "" (U.toString) (U.fromByteString b16) @?= s16,
40 maybe "" (U.toString) (U.fromByteString b16) @?= s16,
39− "conv string to bytes" ~:
41+ testCase "conv string to bytes" $
40 maybe BL.empty (U.toByteString) (U.fromString s16) @?= b16
42 maybe BL.empty (U.toByteString) (U.fromString s16) @?= b16
42 where b16 = BL.pack [1..16]
44 where b16 = BL.pack [1..16]
43 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
45 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
45-- | Test fromByteString with a fixed-input.
47-- | Test fromByteString with a fixed-input.
46−test_fromByteString :: H.Test
48+test_fromByteString :: Test
47test_fromByteString =
49test_fromByteString =
48− "UUID fromByteString" ~:
50+ testCase "UUID fromByteString" $
49 Just inputUUID @=?
51 Just inputUUID @=?
50 U.fromByteString (BL8.pack "\165\202\133f\217\197H5\153\200\225\241>s\181\226")
52 U.fromByteString (BL8.pack "\165\202\133f\217\197H5\153\200\225\241>s\181\226")
52-- | Test fromWords with a fixed-input
54-- | Test fromWords with a fixed-input
53−test_fromWords :: H.Test
55+test_fromWords :: Test
54test_fromWords =
56test_fromWords =
55− "UUID fromWords" ~:
57+ testCase "UUID fromWords" $
56 inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594
58 inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594
58inputUUID :: U.UUID
60inputUUID :: U.UUID
@@ -144,8 +146,9 @@ prop_storableRoundTrip =
144main :: IO ()
146main :: IO ()
146 defaultMain $
148 defaultMain $
148− [ hUnitTestToTests $ H.TestList [
151+ [ [
149 test_null,
152 test_null,
150 test_nil,
153 test_nil,
151 test_conv,
154 test_conv,