quickcheck-text 0.1.1.0 → 0.1.2.0
raw patch · 2 files changed
+18/−2 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- quickcheck-text.cabal +2/−2
- src/Test/QuickCheck/Utf8.hs +16/−0
quickcheck-text.cabal view
@@ -1,5 +1,5 @@ name: quickcheck-text-version: 0.1.1.0+version: 0.1.2.0 synopsis: Alternative arbitrary instance for Text description: The usual Arbitrary instance for Text (in@@ -26,7 +26,7 @@ library exposed-modules: Test.QuickCheck.Utf8 Data.Text.Arbitrary- build-depends: base >=4.7 && <5+ build-depends: base >=4 && <5 , QuickCheck , binary , bytestring
src/Test/QuickCheck/Utf8.hs view
@@ -12,6 +12,8 @@ , shrinkUtf8BS1 -- * Generators for single characters+ , genChar+ , genUtf8Character , oneByte , twoByte , threeByte@@ -82,6 +84,20 @@ inRange :: Int -> Int -> Gen Word8 inRange lo hi = fmap fromIntegral $ elements [lo..hi]++-- | Generate a valid 'Char'. Note that this is UTF-16, not UTF-8, but+-- the intent is the same: the Arbitrary instance for 'Char' in quickcheck+-- makes no attempt to generate valid non-ASCII characters at this time.+genChar :: Gen Char+genChar = (T.head . decodeUtf8) <$> genUtf8Character++-- | A valid UTF-8 character, one to three bytes long.+genUtf8Character :: Gen ByteString+genUtf8Character = oneof [+ oneByte+ , twoByte+ , threeByte+ ] -- | Single-byte UTF-8 (i.e., a standard ASCII byte with a cleared MSB). oneByte :: Gen ByteString