I don't have much experience with elm and I am trying to understand how fuzz tests work. For example how can I write a fuzz test for the List.partition function?
It is defined like:
partition : comparable -> List comparable -> (List comparable, List comparable)
partition pivot l =
(filter (\x -> x < pivot) l, filter (\x -> x >= pivot) l)
I guess one approach would be to install the required modules first. Using the terminal (you can follow the steps here):
After installing, you should import the 3 required libraries:
Finally, you should be able to write your tests, similar to the testing of the
addsOnefunction from here.In order to test the
partitionmethod, I can think of 2 approaches:I would create a helper method that sorts a List of comparables. Then I would make a union between the 2 partitions, sort the union and the initial list and then I would compare them with
Expect.equal.I would create 2 testing methods, one that checks that all comparables in the given list are smaller than the given pivot, and one method that checks if all the comparables are higher than the given pivot.
I will try to come back with some code if needed.