quick_chex v0.2.1 QuickChex.Generators

a module to generate data to be used in properties

Summary

Functions

generates a binary of random size

generates a binary of the given size

generates a binary of size between min_size and max_size

returns a binary sequence with the specified generators

a boolean value

returns an alphabet letter in binary format

generates a list of size size and fill it with the generator supplied

same as list/2, but generate it with a size between min_size and max_size

returns a lowercase letter

generates a non negative integer number between 0 and 1_000_000

generates a non negative integer bound to a min and a max value

returns a number from 0 to 9

returns one of the given values

returns an uppercase letter

Functions

binary()

generates a binary of random size

binary(size)

generates a binary of the given size

binary(min_size, max_size)

generates a binary of size between min_size and max_size

binary_sequence(generators)

returns a binary sequence with the specified generators

Examples

iex> v = QuickChex.Generators.binary_sequence([letter: 2, number: 3])
...> Regex.match?(~r/[A-Za-z]{2}\d{3}/, v)
true

iex> v = QuickChex.Generators.binary_sequence([lowercase_letter: 10,
...> number: 3])
...> Regex.match?(~r/[a-z]{10}\d{3}/, v)
true

iex> v = QuickChex.Generators.binary_sequence([lowercase_letter: 3,
...> uppercase_letter: 3])
...> Regex.match?(~r/[a-z]{3}[A-Z]{3}/, v)
true
bool()

a boolean value

letter()

returns an alphabet letter in binary format

only letters from A to Z uppercase and lowercase

Examples

iex> Regex.match?(~r/[a-zA-Z]{1}/, QuickChex.Generators.letter)
true
list_of(generator, size)

generates a list of size size and fill it with the generator supplied

Examples

iex> import QuickChex.Generators
...> list = list_of(:non_neg_integer, 10)
...> length(list) === 10
true

iex> import QuickChex.Generators
...> list = list_of({:non_neg_integer, [1, 2]}, 10)
...> Enum.all?(list, &is_number/1)
true
list_of(generator, min_size, max_size)

same as list/2, but generate it with a size between min_size and max_size

lowercase_letter()

returns a lowercase letter

Examples

iex> Regex.match?(~r/[a-z]{1}/, QuickChex.Generators.lowercase_letter)
true
non_neg_integer()

generates a non negative integer number between 0 and 1_000_000

Examples

iex> num = QuickChex.Generators.non_neg_integer
...> is_number(num) and num >= 0 and num <= 1_000_000
true
non_neg_integer(min_value, max_value)

generates a non negative integer bound to a min and a max value

Examples

iex> num = QuickChex.Generators.non_neg_integer(1, 2)
...> is_number(num) and num >= 1 and num <= 2
true
number()

returns a number from 0 to 9

Examples

iex> Regex.match?(~r/\d{1}/, QuickChex.Generators.number |> to_string)
true
one_of(list)

returns one of the given values

Examples

iex> QuickChex.Generators.one_of([1])
1

iex> r = QuickChex.Generators.one_of([1, 2])
...> r === 1 or r === 2
true
uppercase_letter()

returns an uppercase letter

Examples

iex> Regex.match?(~r/[A-Z]{1}/, QuickChex.Generators.uppercase_letter)
true