quickcheck-unicode-1.0.1.0: Generator and shrink functions for testing Unicode-related software.

Copyright | (c) 2014-2017 Bryan O'Sullivan
License | BSD-style
Maintainer | bos@serpentine.com
Stability | stable
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell98

Test.QuickCheck.Unicode

Contents

- Newtype wrapper for convenience
- Generators
  - Helpers
  - Basic generators
- Predicates
- Shrinking functions

Description

QuickCheck Generator and shrink functions for testing software that uses Unicode data.

The default `Arbitrary` instance for the `Char` type intentionally generates only ASCII values. This can lead to a false sense of security in cases where Unicode compliance is required, as encodings that span multiple bytes or code units will simply not be exercised at all.

This module deliberately avoids using the `text` and `bytestring` packages to avoid pulling in extra dependencies.

Synopsis

- data Unicode a
- char :: Gen Char
- string :: Gen String
- string1 :: Gen String
- list :: Gen a -> Gen [a]
- list1 :: Gen a -> Gen [a]
- planes :: [(Int, Gen Int)]
- ascii :: Gen Int
- plane0 :: Gen Int
- plane1 :: Gen Int
- plane2 :: Gen Int
- plane14 :: Gen Int
- reserved :: Int -> Bool
- shrinkChar :: Char -> [Char]

# Newtype wrapper for convenience

data Unicode a Source #

A wrapper for `Char` and `String`, for which the `Arbitrary` instance generates full-Unicode characters.

#### Instances

Instances details

Arbitrary (Unicode Char) Source # |
Instance details Defined in Test.QuickCheck.Unicode Methods arbitrary :: Gen (Unicode Char) Source # shrink :: Unicode Char -> [Unicode Char] Source #
Arbitrary (Unicode [Char]) Source # |
Instance details Defined in Test.QuickCheck.Unicode Methods arbitrary :: Gen (Unicode [Char]) Source # shrink :: Unicode [Char] -> [Unicode [Char]] Source #
Read a => Read (Unicode a) Source # |
Instance details Defined in Test.QuickCheck.Unicode Methods readsPrec :: Int -> ReadS (Unicode a) Source # readList :: ReadS [Unicode a] Source # readPrec :: ReadPrec (Unicode a) Source # readListPrec :: ReadPrec [Unicode a] Source #
Show a => Show (Unicode a) Source # |
Instance details Defined in Test.QuickCheck.Unicode Methods showsPrec :: Int -> Unicode a -> ShowS Source # show :: Unicode a -> String Source # showList :: [Unicode a] -> ShowS Source #
Eq a => Eq (Unicode a) Source # |
Instance details Defined in Test.QuickCheck.Unicode Methods (==) :: Unicode a -> Unicode a -> Bool Source # (/=) :: Unicode a -> Unicode a -> Bool Source #
Ord a => Ord (Unicode a) Source # |

Instance details

Defined in Test.QuickCheck.Unicode

Methods

compare :: Unicode a -> Unicode a -> Ordering Source #

(<) :: Unicode a -> Unicode a -> Bool Source #

(<=) :: Unicode a -> Unicode a -> Bool Source #

(>) :: Unicode a -> Unicode a -> Bool Source #

(>=) :: Unicode a -> Unicode a -> Bool Source #

max :: Unicode a -> Unicode a -> Unicode a Source #

min :: Unicode a -> Unicode a -> Unicode a Source #

# Generators

char :: Gen Char Source #

Generate a Unicode code point. This has a much larger range than the default `Arbitrary` instance for `Char`.

string :: Gen String Source #

Generate a list of Unicode code points.

string1 :: Gen String Source #

Generate a non-empty list of Unicode code points.

## Helpers

list :: Gen a -> Gen [a] Source #

Generate a list of values.

list1 :: Gen a -> Gen [a] Source #

Generate a non-empty list of values.

## Basic generators

planes :: [(Int, Gen Int)] Source #

A weighted list of generators that favours ASCII characters, followed by planes 0 and 1.

ascii :: Gen Int Source #

plane0 :: Gen Int Source #

Basic Multilingual Plane.

plane1 :: Gen Int Source #

Supplementary Multilingual Plane.

plane2 :: Gen Int Source #

Supplementary Ideographic Plane.

plane14 :: Gen Int Source #

Supplementary Special-Purpose Plane.

# Predicates

reserved :: Int -> Bool Source #

Indicate whether a code point is reserved.

# Shrinking functions

shrinkChar :: Char -> [Char] Source #

Shrink a Unicode code point.