on master help sign in
uuid-types: Switch to `tasty` for automated tests.
498a38dAntoine Latter
uuid-types/tests/TestUUID.hs+24−22
@@ -8,51 +8,52 @@ import Data.Word
8import qualified Data.UUID.Types as U
8import qualified Data.UUID.Types as U
9import Foreign (alloca, peek, poke)
9import Foreign (alloca, peek, poke)
10import System.IO.Unsafe (unsafePerformIO)
10import System.IO.Unsafe (unsafePerformIO)
11−import qualified Test.HUnit as H
11+
12−import Test.HUnit hiding (Test)
13import Test.QuickCheck hiding ((.&.))
12import Test.QuickCheck hiding ((.&.))
13+
14−import Test.Framework (defaultMain, Test)
14+import Test.Tasty ( defaultMain, TestTree, testGroup )
15−import Test.Framework.Providers.HUnit (hUnitTestToTests)
15+import Test.Tasty.HUnit
16−import Test.Framework.Providers.QuickCheck2 (testProperty)
16+import Test.Tasty.QuickCheck
17
17
18
18
19instance Arbitrary U.UUID where
19instance Arbitrary U.UUID where
20 -- the UUID random instance ignores bounds
20 -- the UUID random instance ignores bounds
21 arbitrary = choose (U.nil, U.nil)
21 arbitrary = choose (U.nil, U.nil)
22
22
23+type Test = TestTree
23
24
24−test_null :: H.Test
25+test_null :: Test
25−test_null = H.TestList [
26+test_null =
27+ testCase "nil is null" $
26− "nil is null" ~: assertBool "" (U.null U.nil)
28+ assertBool "" (U.null U.nil)
27− ]
28
29
29−test_nil :: H.Test
30+test_nil :: Test
30−test_nil = H.TestList [
31+test_nil = testGroup "nil" [
31− "nil string" ~: U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",
32+ testCase "nil string" $ U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",
32− "nil bytes" ~: U.toByteString U.nil @?= BL.pack (replicate 16 0)
33+ testCase "nil bytes" $ U.toByteString U.nil @?= BL.pack (replicate 16 0)
33 ]
34 ]
34
35
35−test_conv :: H.Test
36+test_conv :: Test
36−test_conv = H.TestList [
37+test_conv = testGroup "conversions" [
37− "conv bytes to string" ~:
38+ testCase "conv bytes to string" $
38 maybe "" (U.toString) (U.fromByteString b16) @?= s16,
39 maybe "" (U.toString) (U.fromByteString b16) @?= s16,
39− "conv string to bytes" ~:
40+ testCase "conv string to bytes" $
40 maybe BL.empty (U.toByteString) (U.fromString s16) @?= b16
41 maybe BL.empty (U.toByteString) (U.fromString s16) @?= b16
41 ]
42 ]
42 where b16 = BL.pack [1..16]
43 where b16 = BL.pack [1..16]
43 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
44 s16 = "01020304-0506-0708-090a-0b0c0d0e0f10"
44
45
45-- | Test fromByteString with a fixed-input.
46-- | Test fromByteString with a fixed-input.
46−test_fromByteString :: H.Test
47+test_fromByteString :: Test
47test_fromByteString =
48test_fromByteString =
48− "UUID fromByteString" ~:
49+ testCase "UUID fromByteString" $
49 Just inputUUID @=?
50 Just inputUUID @=?
50 U.fromByteString (BL8.pack "\165\202\133f\217\197H5\153\200\225\241>s\181\226")
51 U.fromByteString (BL8.pack "\165\202\133f\217\197H5\153\200\225\241>s\181\226")
51
52
52-- | Test fromWords with a fixed-input
53-- | Test fromWords with a fixed-input
53−test_fromWords :: H.Test
54+test_fromWords :: Test
54test_fromWords =
55test_fromWords =
55− "UUID fromWords" ~:
56+ testCase "UUID fromWords" $
56 inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594
57 inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594
57
58
58inputUUID :: U.UUID
59inputUUID :: U.UUID
@@ -144,8 +145,9 @@ prop_storableRoundTrip =
144main :: IO ()
145main :: IO ()
145main = do
146main = do
146 defaultMain $
147 defaultMain $
148+ testGroup "tests" $
147 concat $
149 concat $
148− [ hUnitTestToTests $ H.TestList [
150+ [ [
149 test_null,
151 test_null,
150 test_nil,
152 test_nil,
151 test_conv,
153 test_conv,
uuid-types/uuid-types.cabal+3−3
@@ -58,9 +58,9 @@ Test-Suite testuuid
58 bytestring >= 0.9 && < 0.11,
58 bytestring >= 0.9 && < 0.11,
59 HUnit >=1.2 && < 1.3,
59 HUnit >=1.2 && < 1.3,
60 QuickCheck >=2.4 && < 2.9,
60 QuickCheck >=2.4 && < 2.9,
61− test-framework == 0.8.*,
61+ tasty == 0.10.*,
62− test-framework-hunit == 0.3.*,
62+ tasty-hunit == 0.9.*,
63− test-framework-quickcheck2 == 0.3.*
63+ tasty-quickcheck == 0.8.*
64
64
65benchmark benchmark
65benchmark benchmark
66 Type: exitcode-stdio-1.0
66 Type: exitcode-stdio-1.0