MusicXML icon indicating copy to clipboard operation
MusicXML copied to clipboard

Make LilyPond tests round-trip to test encoding

Open jsbean opened this issue 5 years ago • 2 comments

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:

  • Decode MusicXML files from LilyPond test suite
  • Encode the decoded MusicXML model
  • Re-decode the encoded MusicXML data
  • Compare the originally decoded and re-decoded MusicXML model

jsbean avatar Oct 13 '19 18:10 jsbean

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.

DJBen avatar Oct 17 '19 02:10 DJBen

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.

jsbean avatar Oct 17 '19 03:10 jsbean