+ "!Description\n" +
+ " Line one of description\n" +
+ " Line two of description;\n" +
+ "!Format\n" +
+ " DataType=DNA CodeTable=Standard\n" +
+ " NSeqs=2 NSites=12\n" +
+ " Indel=- Identical=. Missing=?;\n\n" +
+ "#U455 CGC GTA\n" +
+ "#CPZANT ATC GGG\n\n" +
+ "#U455 CGA TTT\n" +
+ "#CPZANT CAA TGC\n";
+ //@formatter:on
+ assertEquals("Roundtrip didn't match", expected,
+ formatted);
+ }
+
+ /**
+ * Test reading a MEGA file to an alignment then writing it out in MEGA
+ * format. Verify the output is (functionally) the same as the input.
+ *
+ * @throws IOException
+ */
+ @Test(groups = "Functional")
+ public void testRoundTrip_multilineFormatWithComments()
+ throws IOException
+ {
+ AppletFormatAdapter fa = new AppletFormatAdapter();
+ //@formatter:off
+ AlignmentI al = fa.readFile("#MEGA\n"
+ + "!Title Data with description;\n"
+ + "[ this comment should be ignored\n"
+ + "including [this nested comment]\n"
+ + "]\n"
+ + "!Format \n"
+ + "DataType=DNA CodeTable=Standard\n"
+ + "indel=- Missing=? MatchChar=.;\n\n"
+ + "!Description\n"
+ + " Line one of description\n"
+ + " Line two of description;\n\n"
+ + "#U455 CGC GTA\n"
+ + "#CPZANT ATC GGG\n\n"
+ + "#U455 CGA TTT\n"
+ + "#CPZANT CAA TGC\n",
+ AppletFormatAdapter.PASTE, "MEGA");
+ //@formatter:on
+ MegaFile output = new MegaFile();
+ String formatted = output.print(al);
+ //@formatter:off
+ String expected =
+ "#MEGA\n!Title Data with description;\n" +
+ "!Description\n" +
+ " Line one of description\n" +