CSV Parsing
The first part of the program we’ll work on is handling CSV conversion. No specific order is better than another in this case, and starting with CSV instead of filtering or email rendering is entirely arbitrary. In this section, we’ll explore how to come up with the right type of properties for encoding and decoding CSV, and how to get decent generators for that task. We’ll also see how regular example-based unit tests can be used to strengthen our properties, and see how each fares compared to the other.
CSV is a loose format that nobody really implements the same way. It’s really a big mess, even though RFC 4180[28] tries to provide a simple specification:
-
Each record is on a separate line, separated by CRLF (a \r followed by a ...
Get Property-Based Testing with PropEr, Erlang, and Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.