Permalink
Browse files

Atom signature test methods

  • Loading branch information...
1 parent b64c4e5 commit 888bf608fc1bd4d95584a4713d056613df4ffce8 @gilleain gilleain committed with egonw Jun 15, 2010
@@ -25,6 +25,7 @@
import java.util.List;
import org.openscience.cdk.annotations.TestClass;
+import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
@@ -79,12 +80,14 @@ public AtomSignature(int atomIndex, int height,
super.create(atomIndex, molecule.getAtomCount(), height);
}
+ @TestMethod("getIntLabelTest")
public int getIntLabel(int vertexIndex) {
IAtom atom = molecule.getAtom(vertexIndex);
return atom.getMassNumber();
}
@Override /** {@inheritDoc} */
+ @TestMethod("getConnectedTest")
public int[] getConnected(int vertexIndex) {
IAtom atom = this.molecule.getAtom(vertexIndex);
List<IAtom> connected = this.molecule.getConnectedAtomsList(atom);
@@ -97,6 +100,7 @@ public int getIntLabel(int vertexIndex) {
}
@Override /** {@inheritDoc} */
+ @TestMethod("getEdgeLabelTest")
public String getEdgeLabel(int vertexIndex, int otherVertexIndex) {
IAtom atomA = this.molecule.getAtom(vertexIndex);
IAtom atomB = this.molecule.getAtom(otherVertexIndex);
@@ -116,6 +120,7 @@ public String getEdgeLabel(int vertexIndex, int otherVertexIndex) {
}
@Override /** {@inheritDoc} */
+ @TestMethod("getVertexSymbolTest")
public String getVertexSymbol(int vertexIndex) {
return this.molecule.getAtom(vertexIndex).getSymbol();
}
@@ -27,8 +27,11 @@
import junit.framework.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
/**
@@ -38,6 +41,41 @@
*/
public class AtomSignatureTest extends AbstractSignatureTest {
+ private IAtomContainer atomContainer;
+
+ private AtomSignature atomSignature;
+
+ @Before
+ public void setUp() {
+ atomContainer = builder.newInstance(IAtomContainer.class);
+ atomContainer.addAtom(builder.newInstance(IAtom.class, "C"));
+ atomContainer.addAtom(builder.newInstance(IAtom.class, "C"));
+ atomContainer.addBond(0, 1, IBond.Order.DOUBLE);
+ atomSignature = new AtomSignature(0, atomContainer);
+ }
+
+
+ @Test
+ public void getIntLabelTest() {
+ atomContainer.getAtom(0).setMassNumber(12);
+ Assert.assertEquals(12, atomSignature.getIntLabel(0));
+ }
+
+ @Test
+ public void getConnectedTest() {
+ Assert.assertEquals(1, atomSignature.getConnected(0)[0]);
+ }
+
+ @Test
+ public void getEdgeLabelTest() {
+ Assert.assertEquals("=", atomSignature.getEdgeLabel(0, 1));
+ }
+
+ @Test
+ public void getVertexSymbolTest() {
+ Assert.assertEquals("C", atomSignature.getVertexSymbol(0));
+ }
+
@Test
public void integerInvariantsTest() {
IMolecule isotopeChiralMol = builder.newInstance(IMolecule.class);

0 comments on commit 888bf60

Please sign in to comment.