makhidkarun / traveller_pyroute

Traveller trade route generator
MIT License
14 stars 5 forks source link

Add Hypothesis tests for TradeCodes #71

Closed CyberiaResurrection closed 11 months ago

CyberiaResurrection commented 1 year ago

This PR hooks up the Hypothesis testing library, which enables property-based tests:

  1. For all data matching some specification.
  2. Perform some operations on the data.
  3. Assert something about the result.

Starline parsing has historically been less than robust, and trade code parsing was no better than the rest of it, so this PR started there.

The specification i used was Given an otherwise-valid input string, it should parse cleanly to a well-formed TradeCodes object that then should cleanly round-trip to/from string. As could be expected, smoke poured out of TradeCode parsing. So I went thru and fixed that.