From 0ea90e8f307844dbea5b3016a6250a22f3d71802 Mon Sep 17 00:00:00 2001 From: John May Date: Sun, 4 Nov 2012 12:32:00 +0000 Subject: [PATCH] added unit test to demonstrate bug and correct bug id's for two recents tests Change-Id: If2c12c6dfaad4c7664b5ec6d439f8ddbec9f2ae9 Signed-off-by: Egon Willighagen --- ...)-1-aminoethan-1-ol-multipleBondStereo.cml | 33 ++++++++++ src/test/data/cml/(1R)-1-aminoethan-1-ol.cml | 6 +- .../org/openscience/cdk/io/CMLReaderTest.java | 64 ++++++++++++++++++- 3 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/test/data/cml/(1R)-1-aminoethan-1-ol-multipleBondStereo.cml diff --git a/src/test/data/cml/(1R)-1-aminoethan-1-ol-multipleBondStereo.cml b/src/test/data/cml/(1R)-1-aminoethan-1-ol-multipleBondStereo.cml new file mode 100644 index 00000000000..612608dd42a --- /dev/null +++ b/src/test/data/cml/(1R)-1-aminoethan-1-ol-multipleBondStereo.cml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + W + + + + + + + diff --git a/src/test/data/cml/(1R)-1-aminoethan-1-ol.cml b/src/test/data/cml/(1R)-1-aminoethan-1-ol.cml index fd241a181d8..6b6de220323 100644 --- a/src/test/data/cml/(1R)-1-aminoethan-1-ol.cml +++ b/src/test/data/cml/(1R)-1-aminoethan-1-ol.cml @@ -2,9 +2,9 @@ - diff --git a/src/test/org/openscience/cdk/io/CMLReaderTest.java b/src/test/org/openscience/cdk/io/CMLReaderTest.java index 6fc6f8bdac6..b5cbb2892a8 100644 --- a/src/test/org/openscience/cdk/io/CMLReaderTest.java +++ b/src/test/org/openscience/cdk/io/CMLReaderTest.java @@ -36,6 +36,7 @@ import org.openscience.cdk.tools.periodictable.PeriodicTable; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; @@ -70,7 +71,7 @@ public void testSetReader_Reader() throws Exception { * Ensure stereoBond content is read if the usual "dictRef" attribute is not * supplied * - * @cdk.bug 3557907 + * @cdk.bug 1248 */ @Test public void testBug3557907() throws FileNotFoundException, CDKException { @@ -102,7 +103,7 @@ public void testBug3557907() throws FileNotFoundException, CDKException { /** * Ensure correct atomic numbers are read and does not default to 1 * - * @cdk.bug 3553328 + * @cdk.bug 1245 */ @Test public void testBug3553328() throws FileNotFoundException, CDKException { @@ -126,6 +127,65 @@ public void testBug3553328() throws FileNotFoundException, CDKException { PeriodicTable.getAtomicNumber(atom.getSymbol()), atom.getAtomicNumber()); } + } + /** + * Ensures that when multiple stereo is set the dictRef is favoured + * and the charContent is not used. Here is an example of what we expect + * to read. + * + *
{@code
+     * 
+     *      
+     * 
+     *
+     * 
+     *     W 
+     * 
+     *
+     * 
+     *    W 
+     * 
+     *
+     * 
+     *    H 
+     * 
+     * }
+ * + * @cdk.bug 1274 + * @see #testBug1248() + */ + @Test + public void testBug1274() throws CDKException, IOException { + + InputStream in = getClass().getResourceAsStream("/data/cml/(1R)-1-aminoethan-1-ol-multipleBondStereo.cml"); + CMLReader reader = new CMLReader(in); + try { + IChemFile cfile = reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IChemFile.class)); + + + Assert.assertNotNull("ChemFile was null", cfile); + + List containers = ChemFileManipulator.getAllAtomContainers(cfile); + + Assert.assertEquals("expected a single atom container", 1, containers.size()); + + IAtomContainer container = containers.get(0); + + Assert.assertNotNull("null atom container read", container); + + // we check here that the charContent is not used and also that more then + // one stereo isn't set + Assert.assertEquals("expected non-stereo bond", + IBond.Stereo.NONE, container.getBond(0).getStereo()); + Assert.assertEquals("expected Hatch (Down) Bond", + IBond.Stereo.DOWN, container.getBond(1).getStereo()); + Assert.assertEquals("expected non-stereo bond", + IBond.Stereo.NONE, container.getBond(2).getStereo()); + + } finally { + reader.close(); + } } + }