on master help sign in
Add tests for fromWords and fromByteString against fixed input.
78414ebAntoine Latter
tests/TestUUID.hs+20−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE ViewPatterns #-}
2{-# LANGUAGE ViewPatterns #-}
2import Control.Monad (replicateM)
3import Control.Monad (replicateM)
3import Data.Bits
4import Data.Bits
@@ -82,6 +83,22 @@ test_v5 = H.TestList [
82 where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
83 where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
83 uV5 = fromJust $ U.fromString "21f7f8de-8051-5b89-8680-0195ef798b6a"
84 uV5 = fromJust $ U.fromString "21f7f8de-8051-5b89-8680-0195ef798b6a"
84
85
86+
87+-- | Test fromByteString with a fixed-input.
88+test_fromByteString :: H.Test
89+test_fromByteString =
90+ "UUID fromByteString" ~:
91+ Just inputUUID @=? U.fromByteString "\165\202\133f\217\197H5\153\200\225\241>s\181\226"
92+
93+-- | Test fromWords with a fixed-input
94+test_fromWords :: H.Test
95+test_fromWords =
96+ "UUID fromWords" ~:
97+ inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594
98+
99+inputUUID :: U.UUID
100+inputUUID = read "a5ca8566-d9c5-4835-99c8-e1f13e73b5e2"
101+
85prop_stringRoundTrip :: Test
102prop_stringRoundTrip :: Test
86prop_stringRoundTrip = testProperty "String round trip" stringRoundTrip
103prop_stringRoundTrip = testProperty "String round trip" stringRoundTrip
87 where stringRoundTrip :: U.UUID -> Bool
104 where stringRoundTrip :: U.UUID -> Bool
@@ -201,7 +218,9 @@ main = do
201 test_conv,
218 test_conv,
202 test_v1 v1s,
219 test_v1 v1s,
203 test_v3,
220 test_v3,
204− test_v5
221+ test_v5,
222+ test_fromByteString,
223+ test_fromWords
205 ]
224 ]
206 , [ prop_stringRoundTrip,
225 , [ prop_stringRoundTrip,
207 prop_readShowRoundTrip,
226 prop_readShowRoundTrip,