Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More unit tests. All methods are now at least tested once. (closes #3…

…005889)

Change-Id: I305ed297ff335cdd20cd119c84c3968e6e7b13d6
  • Loading branch information...
commit 6d051a6723a40eb1fc8c2e7369d04f4490aa229b 1 parent 8a4d7d8
@egonw egonw authored
View
1  src/META-INF/test-inchi.cdkdepends
@@ -9,3 +9,4 @@ cdk-valencycheck.jar
cdk-test.jar
cdk-inchi.jar
cdk-smiles.jar
+cdk-silent.jar
View
4 src/main/org/openscience/cdk/inchi/InChIToStructure.java
@@ -142,6 +142,7 @@ protected InChIToStructure(String inchi, IChemObjectBuilder builder, List<String
*
* @throws CDKException
*/
+ @TestMethod("testGetAtomContainer_IChemObjectBuilder")
protected void generateAtomContainerFromInchi(IChemObjectBuilder builder) throws CDKException {
try {
output = JniInchiWrapper.getStructureFromInchi(input);
@@ -289,6 +290,7 @@ public INCHI_RET getReturnStatus() {
/**
* Gets generated (error/warning) messages.
*/
+ @TestMethod("testGetMessage")
public String getMessage() {
return(output.getMessage());
}
@@ -296,6 +298,7 @@ public String getMessage() {
/**
* Gets generated log.
*/
+ @TestMethod("testGetLog")
public String getLog() {
return(output.getLog());
}
@@ -309,6 +312,7 @@ public String getLog() {
* <br>y=1 => Main layer or Mobile-H
* <br>y=0 => Fixed-H layer
*/
+ @TestMethod("testGetWarningFlags")
public long[][] getWarningFlags() {
return(output.getWarningFlags());
}
View
57 src/test/org/openscience/cdk/inchi/InChIToStructureTest.java
@@ -27,6 +27,8 @@
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond.Order;
+import org.openscience.cdk.silent.AtomContainer;
+import org.openscience.cdk.silent.SilentChemObjectBuilder;
/**
* TestCase for the {@link InChIToStructure} class.
@@ -84,4 +86,59 @@ public void testGetReturnStatus_EOF() throws CDKException {
Assert.assertEquals(INCHI_RET.EOF, returnStatus);
}
+ @Test
+ public void testGetMessage() throws CDKException {
+ InChIToStructure parser = new InChIToStructure(
+ "InChI=1S/CH5/h1H4", DefaultChemObjectBuilder.getInstance()
+ );
+ parser.getAtomContainer();
+ String message = parser.getMessage();
+ Assert.assertNotNull(message);
+ }
+
+ @Test
+ public void testGetMessageNull() throws CDKException {
+ InChIToStructure parser = new InChIToStructure(
+ "InChI=1S", DefaultChemObjectBuilder.getInstance()
+ );
+ parser.getAtomContainer();
+ String message = parser.getMessage();
+ Assert.assertNull(message);
+ }
+
+ @Test
+ public void testGetLog() throws CDKException {
+ InChIToStructure parser = new InChIToStructure(
+ "InChI=1S/CH5/h1H4", DefaultChemObjectBuilder.getInstance()
+ );
+ parser.getAtomContainer();
+ String message = parser.getMessage();
+ Assert.assertNotNull(message);
+ }
+
+ @Test
+ public void testGetWarningFlags() throws CDKException {
+ InChIToStructure parser = new InChIToStructure(
+ "InChI=1S/CH5/h1H4", DefaultChemObjectBuilder.getInstance()
+ );
+ parser.getAtomContainer();
+ long[][] flags = parser.getWarningFlags();
+ Assert.assertNotNull(flags);
+ Assert.assertEquals(2, flags.length);
+ Assert.assertEquals(2, flags[0].length);
+ Assert.assertEquals(2, flags[1].length);
+ }
+
+ @Test
+ public void testGetAtomContainer_IChemObjectBuilder() throws CDKException {
+ InChIToStructure parser = new InChIToStructure(
+ "InChI=1S/CH5/h1H4", DefaultChemObjectBuilder.getInstance()
+ );
+ parser.generateAtomContainerFromInchi(SilentChemObjectBuilder.getInstance());
+ IAtomContainer container = parser.getAtomContainer();
+ // test if the created IAtomContainer is done with the Silent module...
+ // OK, this is not typical use, but maybe the above generate method should be private
+ Assert.assertTrue(container instanceof AtomContainer);
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.