on master help sign in
Add tests for fromWords and fromByteString against fixed input.

Fixes #2.

commit78414ebb2934d9fecbe1c5fb3f46052ba1727e10 authorAntoine Latter <aslatter@gmail.com> dateWed 24 Dec 2014, 13:45 (12 years ago) parent807db7f
1 file changed+20−1
tests/TestUUID.hs+20−1
tests/TestUUID.hs+20−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
12{-# LANGUAGE ViewPatterns #-}
23import Control.Monad (replicateM)
34import Data.Bits
@@ -82,6 +83,22 @@ test_v5 = H.TestList [
8283 where name = map (fromIntegral . ord) "www.widgets.com" :: [Word8]
8384 uV5 = fromJust $ U.fromString "21f7f8de-8051-5b89-8680-0195ef798b6a"
8485
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+
85102prop_stringRoundTrip :: Test
86103prop_stringRoundTrip = testProperty "String round trip" stringRoundTrip
87104 where stringRoundTrip :: U.UUID -> Bool
@@ -201,7 +218,9 @@ main = do
201218 test_conv,
202219 test_v1 v1s,
203220 test_v3,
204− test_v5
221+ test_v5,
222+ test_fromByteString,
223+ test_fromWords
205224 ]
206225 , [ prop_stringRoundTrip,
207226 prop_readShowRoundTrip,