uuid-types 1.0.0 → 1.0.1
raw patch · 5 files changed
+38/−125 lines, 5 filesdep +tastydep +tasty-hunitdep +tasty-quickcheckdep −test-frameworkdep −test-framework-hunitdep −test-framework-quickcheck2dep ~QuickCheckdep ~basedep ~bytestring
Dependencies added: tasty, tasty-hunit, tasty-quickcheck
Dependencies removed: test-framework, test-framework-hunit, test-framework-quickcheck2
Dependency ranges changed: QuickCheck, base, bytestring, criterion, deepseq, random
Files
- CHANGES +4/−0
- tests/BenchByteString.hs +0/−82
- tests/BenchUUID.hs +1/−1
- tests/TestUUID.hs +26/−23
- uuid-types.cabal +7/−19
CHANGES view
@@ -1,3 +1,7 @@+1.0.1++- Update dependencies in tests and benchmarks.+ 1.0.0 - Initial split from "uuid-1.3.8"
− tests/BenchByteString.hs
@@ -1,82 +0,0 @@-import Control.Applicative ((<*>))-import Data.Functor ((<$>))--import Data.ByteString (ByteString)-import qualified Data.ByteString.Char8 as BC8-import System.Random-import Test.QuickCheck--import Criterion-import Criterion.Main--import Data.UUID.Types--instance Arbitrary UUID where- arbitrary =- fromWords <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary---- Testing what we do in the codebase-fromASCIIBytes_naive :: ByteString -> Maybe UUID-fromASCIIBytes_naive = fromString . BC8.unpack--toASCIIBytes_naive :: UUID -> ByteString-toASCIIBytes_naive = BC8.pack . toString--randomUUIDs :: IO [UUID]-randomUUIDs = sample' arbitrary--randomCorrect :: IO [String]-randomCorrect = map toString <$> randomUUIDs--randomSlightlyWrong :: IO [String]-randomSlightlyWrong = mapM screw =<< randomCorrect- where- screw s = do- ix <- randomRIO (0, length s - 1)- return (take ix s ++ "x" ++ drop (ix + 1) s)--randomVeryWrong :: IO [String]-randomVeryWrong = sample' arbitrary--main :: IO ()-main = do- uuids <- randomUUIDs- correct <- randomCorrect- let correctBytes = map BC8.pack correct- slightlyWrong <- randomSlightlyWrong- let slightlyWrongBytes = map BC8.pack slightlyWrong- veryWrong <- randomVeryWrong- let veryWrongBytes = map BC8.pack veryWrong-- defaultMain- [ bgroup "decoding"- [ bcompare- [ bgroup "correct"- [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) correctBytes)- , bench "fromString" (nf (map fromString) correct)- , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) correctBytes)- ]- ]- , bcompare- [ bgroup "slightly wrong"- [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) slightlyWrongBytes)- , bench "fromString" (nf (map fromString) slightlyWrong)- , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) slightlyWrongBytes)- ]- ]- , bcompare- [ bgroup "very wrong"- [ bench "fromASCIIBytes" (nf (map fromASCIIBytes) veryWrongBytes)- , bench "fromString" (nf (map fromString) veryWrong)- , bench "fromASCIIBytes_naive" (nf (map fromASCIIBytes_naive) veryWrongBytes)- ]- ]- ]- , bcompare- [ bgroup "encoding"- [ bench "toASCIIBytes" (nf (map toASCIIBytes) uuids)- , bench "toString" (nf (map toString) uuids)- , bench "toASCIIBytes_naive" (nf (map toASCIIBytes_naive) uuids)- ]- ]- ]
tests/BenchUUID.hs view
@@ -55,7 +55,7 @@ bgroup "storable" [ bench "peek" $ nfIO (peek uuidPtr),- bench "poke" $ poke uuidPtr u1+ bench "poke" $ whnfIO $ poke uuidPtr u1 ] ]
tests/TestUUID.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ViewPatterns #-}+ import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 import qualified Data.ByteString.Char8 as BC8@@ -8,51 +9,52 @@ import qualified Data.UUID.Types as U import Foreign (alloca, peek, poke) import System.IO.Unsafe (unsafePerformIO)-import qualified Test.HUnit as H-import Test.HUnit hiding (Test)-import Test.QuickCheck hiding ((.&.))-import Test.Framework (defaultMain, Test)-import Test.Framework.Providers.HUnit (hUnitTestToTests)-import Test.Framework.Providers.QuickCheck2 (testProperty) +import Test.QuickCheck ( Arbitrary(arbitrary), choose ) +import Test.Tasty ( defaultMain, TestTree, testGroup )+import Test.Tasty.HUnit ( assertBool, (@?=), (@=?), testCase )+import Test.Tasty.QuickCheck ( testProperty )++ instance Arbitrary U.UUID where -- the UUID random instance ignores bounds arbitrary = choose (U.nil, U.nil) +type Test = TestTree -test_null :: H.Test-test_null = H.TestList [- "nil is null" ~: assertBool "" (U.null U.nil)- ]+test_null :: Test+test_null =+ testCase "nil is null" $+ assertBool "" (U.null U.nil) -test_nil :: H.Test-test_nil = H.TestList [- "nil string" ~: U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",- "nil bytes" ~: U.toByteString U.nil @?= BL.pack (replicate 16 0)+test_nil :: Test+test_nil = testGroup "nil" [+ testCase "nil string" $ U.toString U.nil @?= "00000000-0000-0000-0000-000000000000",+ testCase "nil bytes" $ U.toByteString U.nil @?= BL.pack (replicate 16 0) ] -test_conv :: H.Test-test_conv = H.TestList [- "conv bytes to string" ~:+test_conv :: Test+test_conv = testGroup "conversions" [+ testCase "conv bytes to string" $ maybe "" (U.toString) (U.fromByteString b16) @?= s16,- "conv string to bytes" ~:+ testCase "conv string to bytes" $ maybe BL.empty (U.toByteString) (U.fromString s16) @?= b16 ] where b16 = BL.pack [1..16] s16 = "01020304-0506-0708-090a-0b0c0d0e0f10" -- | Test fromByteString with a fixed-input.-test_fromByteString :: H.Test+test_fromByteString :: Test test_fromByteString =- "UUID fromByteString" ~:+ testCase "UUID fromByteString" $ Just inputUUID @=? U.fromByteString (BL8.pack "\165\202\133f\217\197H5\153\200\225\241>s\181\226") -- | Test fromWords with a fixed-input-test_fromWords :: H.Test+test_fromWords :: Test test_fromWords =- "UUID fromWords" ~:+ testCase "UUID fromWords" $ inputUUID @=? U.fromWords 2781513062 3653584949 2580079089 1047770594 inputUUID :: U.UUID@@ -144,8 +146,9 @@ main :: IO () main = do defaultMain $+ testGroup "tests" $ concat $- [ hUnitTestToTests $ H.TestList [+ [ [ test_null, test_nil, test_conv,
uuid-types.cabal view
@@ -1,5 +1,5 @@ Name: uuid-types-Version: 1.0.0+Version: 1.0.1 Copyright: (c) 2008-2014 Antoine Latter Author: Antoine Latter Maintainer: aslatter@gmail.com@@ -57,10 +57,10 @@ uuid-types, bytestring >= 0.9 && < 0.11, HUnit >=1.2 && < 1.3,- QuickCheck >=2.4 && < 2.8,- test-framework == 0.8.*,- test-framework-hunit == 0.3.*,- test-framework-quickcheck2 == 0.3.*+ QuickCheck >=2.4 && < 2.9,+ tasty == 0.10.*,+ tasty-hunit == 0.9.*,+ tasty-quickcheck == 0.8.* benchmark benchmark Type: exitcode-stdio-1.0@@ -72,18 +72,6 @@ uuid-types, bytestring >= 0.9 && < 0.11, containers >= 0.4 && < 0.6,- criterion >= 0.4 && < 0.9,- deepseq >= 1.1 && < 1.4,+ criterion >= 0.4 && < 1.2,+ deepseq >= 1.1 && < 1.5, random >= 1.0.1 && < 1.2--benchmark benchbytestring- Type: exitcode-stdio-1.0- Hs-Source-Dirs: tests- Main-Is: BenchByteString.hs- Ghc-Options: -threaded -rtsopts -Wall -O2 -fno-warn-orphans- Build-Depends: base >= 4 && < 5- , uuid-types- , bytestring >= 0.10- , criterion >= 0.8- , random >= 1.0- , QuickCheck >= 2