dn-m / MusicXML

Implementation of the musicXML specification in Swift
MIT License
69 stars 19 forks source link

Make LilyPond tests round-trip to test encoding #154

Open jsbean opened 4 years ago

jsbean commented 4 years ago

We currently only test that we can decode the LilyPond test suite without throwing errors. Now, let's up the ante by making the LilyPond tests perform the following maneuver:

DJBen commented 4 years ago

I've tried a bit round-trip testing for custom examples, and I found that the current state of XMLCoder does not support pretty printing - meaning the model -> xml conversion is never going to be the same as the original xml.

Neither we have any tools to trim all spaces between element tags reliably for xml, so we cannot compare the trimmed version of xml to the generated xml.

jsbean commented 4 years ago

You can set XMLEncoder.outputFormatting = .prettyPrinted.

That said, I don’t think we need to test the concrete encoded values directly. Instead, we should test the semantics of the decoded to the decoded-encoded-decoded values.