This is a simple project to play with QuickCheck and learn.
QuickCheck is an Erlang property-based testing tool, developed by Quviq.
This is the result of following The Little Elixir & OTP Guidebook book from Benjamin Tan Wei Hao, released in 2017 by Manning Publications.
From what I've learned:
- Encoding and decoding
- Serializing and deserializing
- Splitting and joining
- Setting and getting
An invariant is a property that remains unchanged when a specific transformation is applied.
- A sort function always sorts elements in order.
- A monotonically increasing function is always such that the former element is less than or equal to the next element.
Suppose you’ve developed a sorting algorithm that can perform sorting in constant time. One simple way to test your implementation is against an existing implementation that’s known to work well. For example, you can test your custom implementation with one from Erlang:
property "List.super_sort/1" do
forall l <- list(int) do
ensure List.super_sort(l) == :lists.sort(l)
end
end
Calling foo/2
twice is the same as doing it once because it will yield the same result when it’s performed once or performed repeatedly. One example:
property "calling Enum.uniq/1 twice has no effect" do
forall l <- list(int) do
ensure(l |> Enum.uniq() == l |> Enum.uniq() |> Enum.uniq())
end
end
First, head over to QuviQ, and download QuickCheck (Mini). Here are the steps once you’ve downloaded the file:
- Unzip the file and cd into the resulting folder.
- Run
iex
- Run
:eqc_install.install()
Then, go to this project's root and run:
mix deps.get