bytestring-arbitrary-0.0.1: Arbitrary instances for ByteStrings

Safe HaskellNone

Data.ByteString.Arbitrary

Synopsis

Documentation

newtype ArbByteString Source

A ByteString wrapper so we can implement Arbitrary for ByteString. This will currently generate random ByteStrings of length 0 to 100KB.

Constructors

ABS 

Fields

fromABS :: ByteString
 

newtype ArbByteString1M Source

A wrapper to generate 1MB bytestrings. The shrink implementation still returns ArbByteString1M instances, of course, but they're smaller than 1MB.

Constructors

ABS1M 

newtype ArbByteString10M Source

A wrapper to generate 10MB bytestrings. I should really figure out how type-level Nats work, so one can just do (ArbByteStringN 10000000) and have selectable sizes, but I don't see how to do that yet, so 10MB is as big as this library goes. As with the 1MB version, shrink here will generate ArbByteString10M instances that wrap ByteStrings smaller than 10MB.

Constructors

ABS10M 

fastRandBs :: Int -> Gen ByteStringSource

Generate a bunch of binary data quickly. This abuses the cryptohash skein function to generate a megabyte of data at a time, and then concats chunks until it has enough.

slowRandBs :: Int -> Gen ByteStringSource

Generate binary data slowly. This generates a list of Word8s, and then uses Data.ByteString.pack to concatenate it into a single ByteString.