Skip to content

Commit

Permalink
Added unit test for serialization of null formal charges into the MDL…
Browse files Browse the repository at this point in the history
… molfile format (which currently fails)

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Jun 5, 2009
1 parent e1da4c0 commit df57aea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/org/openscience/cdk/io/MDLWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,21 @@ public class MDLWriterTest extends ChemObjectIOTest {
String output = writer.toString();
Assert.assertEquals("Test for zero length pseudo atom label in MDL file", -1, output.indexOf("0.0000 0.0000 0.0000 0 0 0 0 0 0 0 0 0 0 0 0"));
}

@Test public void testNullFormalCharge() throws Exception {
StringWriter writer = new StringWriter();
IMolecule molecule = builder.newMolecule();
IAtom atom = builder.newAtom("C");
atom.setFormalCharge(null);
molecule.addAtom(atom);

MDLWriter mdlWriter = new MDLWriter(writer);
mdlWriter.write(molecule);
String output = writer.toString();
// test ensures that the writer does not throw an exception on
// null formal charges, so a mere assert on output being non-zero
// length is enough
Assert.assertNotNull(output);
Assert.assertNotSame(0, output.length());
}
}

0 comments on commit df57aea

Please sign in to comment.