Skip to content

Commit

Permalink
Atom signature test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gilleain authored and egonw committed Jun 23, 2010
1 parent b64c4e5 commit 888bf60
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/org/openscience/cdk/signature/AtomSignature.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -97,6 +100,7 @@ public int[] getConnected(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);
Expand All @@ -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();
}
Expand Down
38 changes: 38 additions & 0 deletions src/test/org/openscience/cdk/signature/AtomSignatureTest.java
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down

0 comments on commit 888bf60

Please sign in to comment.