|
22 | 22 |
|
23 | 23 | import org.junit.Assert;
|
24 | 24 | import org.junit.Test;
|
| 25 | +import org.openscience.cdk.interfaces.IBond; |
25 | 26 | import org.openscience.cdk.test.CDKTestCase;
|
26 | 27 | import org.openscience.cdk.DefaultChemObjectBuilder;
|
27 | 28 | import org.openscience.cdk.exception.CDKException;
|
|
35 | 36 | import org.openscience.cdk.stereo.ExtendedTetrahedral;
|
36 | 37 |
|
37 | 38 | import java.util.Iterator;
|
| 39 | +import java.util.List; |
38 | 40 |
|
39 | 41 | import static org.hamcrest.CoreMatchers.instanceOf;
|
40 | 42 | import static org.hamcrest.CoreMatchers.is;
|
@@ -272,12 +274,39 @@ public void testExtendedCisTrans() throws Exception {
|
272 | 274 | SilentChemObjectBuilder.getInstance()).getAtomContainer();
|
273 | 275 | assertNotNull(mol);
|
274 | 276 | int nExtendedCisTrans = 0;
|
275 |
| - for (IStereoElement se : mol.stereoElements()) { |
276 |
| - if (se.getConfig() != IStereoElement.CU) |
| 277 | + for (IStereoElement<?,?> se : mol.stereoElements()) { |
| 278 | + if (se.getConfigClass() == IStereoElement.CU) |
277 | 279 | nExtendedCisTrans++;
|
278 | 280 | else
|
279 | 281 | Assert.fail("Expected onl extended cis/trans");
|
280 | 282 | }
|
281 | 283 | Assert.assertEquals(1, nExtendedCisTrans);
|
282 | 284 | }
|
| 285 | + |
| 286 | + /** |
| 287 | + * Make sure the IBond{beg,end} storage order is correct for the |
| 288 | + * IStereoElement |
| 289 | + * @throws Exception |
| 290 | + */ |
| 291 | + @Test |
| 292 | + @SuppressWarnings("unchecked") |
| 293 | + public void ensureBondStorageOrder() throws Exception { |
| 294 | + IAtomContainer mol = InChIGeneratorFactory.getInstance() |
| 295 | + .getInChIToStructure("InChI=1S/C16H25NO/c1-14(2)8-6-9-15(3)10-7-11-16(18)17-12-4-5-13-17/h7-8,10-11H,4-6,9,12-13H2,1-3H3/b11-7+,15-10+", |
| 296 | + SilentChemObjectBuilder.getInstance()).getAtomContainer(); |
| 297 | + assertNotNull(mol); |
| 298 | + int nCisTrans = 0; |
| 299 | + for (IStereoElement<?,?> se : mol.stereoElements()) { |
| 300 | + if (se.getConfigClass() == IStereoElement.CisTrans) { |
| 301 | + nCisTrans++; |
| 302 | + IStereoElement<IBond,IBond> ctse = (IStereoElement<IBond,IBond>)se; |
| 303 | + IBond bond = ctse.getFocus(); |
| 304 | + List<IBond> carriers = ctse.getCarriers(); |
| 305 | + Assert.assertEquals(2, carriers.size()); |
| 306 | + Assert.assertTrue(carriers.get(0).contains(bond.getBegin())); |
| 307 | + Assert.assertTrue(carriers.get(1).contains(bond.getEnd())); |
| 308 | + } |
| 309 | + } |
| 310 | + Assert.assertEquals(2, nCisTrans); |
| 311 | + } |
283 | 312 | }
|
0 commit comments