Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Testing of the InChI generator

Change-Id: I5d67a33c596d1fadf96fef192cbd606bca710f6a
  • Loading branch information...
commit 8a4d7d845a8d33d04277ff55b2ac1b619baa0604 1 parent 2b851cf
Egon Willighagen egonw authored
3  src/main/org/openscience/cdk/inchi/InChIGenerator.java
@@ -416,6 +416,7 @@ public String getInchiKey() throws CDKException {
416 416 /**
417 417 * Gets auxillary information.
418 418 */
  419 + @TestMethod("testGetAuxInfo")
419 420 public String getAuxInfo() {
420 421 return(output.getAuxInfo());
421 422 }
@@ -423,6 +424,7 @@ public String getAuxInfo() {
423 424 /**
424 425 * Gets generated (error/warning) messages.
425 426 */
  427 + @TestMethod("testGetMessage,testGetWarningMessage")
426 428 public String getMessage() {
427 429 return(output.getMessage());
428 430 }
@@ -430,6 +432,7 @@ public String getMessage() {
430 432 /**
431 433 * Gets generated log.
432 434 */
  435 + @TestMethod("testGetLog")
433 436 public String getLog() {
434 437 return(output.getLog());
435 438 }
46 src/test/org/openscience/cdk/inchi/InChIGeneratorTest.java
... ... @@ -1,5 +1,5 @@
1 1 /* Copyright (C) 2006-2007 Sam Adams <sea36@users.sf.net>
2   - * 2010 Egon Willighagen <egonw@users.sf.net>
  2 + * 2010,2012 Egon Willighagen <egonw@users.sf.net>
3 3 *
4 4 * Contact: cdk-devel@lists.sourceforge.net
5 5 *
@@ -25,6 +25,7 @@
25 25 import org.openscience.cdk.*;
26 26 import org.openscience.cdk.interfaces.IAtom;
27 27 import org.openscience.cdk.interfaces.IAtomContainer;
  28 +import org.openscience.cdk.interfaces.IBond.Order;
28 29
29 30 import javax.vecmath.Point2d;
30 31 import javax.vecmath.Point3d;
@@ -60,7 +61,48 @@ protected InChIGeneratorFactory getFactory() throws Exception {
60 61 Assert.assertEquals(gen.getReturnStatus(), INCHI_RET.OKAY);
61 62 Assert.assertEquals("InChI=1/ClH/h1H", gen.getInchi());
62 63 }
63   -
  64 +
  65 + @Test public void testGetLog() throws Exception {
  66 + IAtomContainer ac = new AtomContainer();
  67 + ac.addAtom(new Atom("Cl"));
  68 + InChIGenerator gen = getFactory().getInChIGenerator(ac,"FixedH");
  69 + Assert.assertNotNull(gen.getLog());
  70 + }
  71 +
  72 + @Test public void testGetAuxInfo() throws Exception {
  73 + IAtomContainer ac = new AtomContainer();
  74 + IAtom a1 = new Atom("C");
  75 + IAtom a2 = new Atom("C");
  76 + a1.setImplicitHydrogenCount(3);
  77 + a2.setImplicitHydrogenCount(3);
  78 + ac.addAtom(a1);
  79 + ac.addAtom(a2);
  80 + ac.addBond(new Bond(a1, a2, CDKConstants.BONDORDER_SINGLE));
  81 + InChIGenerator gen = getFactory().getInChIGenerator(ac);
  82 + Assert.assertNotNull(gen.getAuxInfo());
  83 + Assert.assertTrue(gen.getAuxInfo().startsWith("AuxInfo="));
  84 + }
  85 +
  86 + @Test public void testGetMessage() throws Exception {
  87 + IAtomContainer ac = new AtomContainer();
  88 + ac.addAtom(new Atom("Cl"));
  89 + InChIGenerator gen = getFactory().getInChIGenerator(ac,"FixedH");
  90 + Assert.assertNull(
  91 + "Because this generation should work, I expected a null message String.",
  92 + gen.getMessage()
  93 + );
  94 + }
  95 +
  96 + @Test public void testGetWarningMessage() throws Exception {
  97 + IAtomContainer ac = new AtomContainer();
  98 + ac.addAtom(new Atom("Cl"));
  99 + ac.addAtom(new Atom("H"));
  100 + ac.addBond(0, 1, Order.TRIPLE);
  101 + InChIGenerator gen = getFactory().getInChIGenerator(ac);
  102 + Assert.assertNotNull(gen.getMessage());
  103 + Assert.assertTrue(gen.getMessage().contains("Accepted unusual valence"));
  104 + }
  105 +
64 106 /**
65 107 * Tests charge is correctly passed to InChI.
66 108 *

0 comments on commit 8a4d7d8

Please sign in to comment.
Something went wrong with that request. Please try again.