Skip to content

Commit

Permalink
Merge branch 'fix' into cdk-1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarshi committed May 18, 2012
2 parents 174493c + 3d0b0e5 commit 84b2e87
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/main/org/openscience/cdk/DefaultChemObjectBuilder.java
Expand Up @@ -383,7 +383,7 @@ private <T extends ICDKObject>T newElectronContainerInstance(
return (T)new Bond();
} else if (params.length == 2 &&
params[0] instanceof IAtom &&
params[0] instanceof IAtom) {
params[1] instanceof IAtom) {
return (T)new Bond((IAtom)params[0], (IAtom)params[1]);
} else if (params.length == 3 &&
params[0] instanceof IAtom &&
Expand Down Expand Up @@ -421,7 +421,8 @@ private <T extends ICDKObject>T newElectronContainerInstance(
} else {
// the IBond(IAtom[]) constructor
boolean allIAtom = true;
for (int i=0; i<(params.length-1) && allIAtom; i++) {
for (int i=0; i<params.length && allIAtom; i++) {
System.out.println(params[i]);
if (!(params[i] instanceof IAtom)) allIAtom = false;
}
if (allIAtom) {
Expand Down
Expand Up @@ -376,7 +376,7 @@ private <T extends ICDKObject>T newElectronContainerInstance(
return (T)new Bond();
} else if (params.length == 2 &&
params[0] instanceof IAtom &&
params[0] instanceof IAtom) {
params[1] instanceof IAtom) {
return (T)new Bond((IAtom)params[0], (IAtom)params[1]);
} else if (params.length == 3 &&
params[0] instanceof IAtom &&
Expand Down Expand Up @@ -414,7 +414,7 @@ private <T extends ICDKObject>T newElectronContainerInstance(
} else {
// the IBond(IAtom[]) constructor
boolean allIAtom = true;
for (int i=0; i<(params.length-1) && allIAtom; i++) {
for (int i=0; i<params.length && allIAtom; i++) {
if (!(params[i] instanceof IAtom)) allIAtom = false;
}
if (allIAtom) {
Expand Down
15 changes: 14 additions & 1 deletion src/test/org/openscience/cdk/AbstractChemObjectBuilderTest.java
Expand Up @@ -224,7 +224,20 @@ public void testNewAtom_IElement() {
);
Assert.assertNotNull(bond);
}


/**
* @cdk.bug 3526870
*/
@Test(expected=IllegalArgumentException.class)
public void testNewBond_IAtom_IMolecule() {
IChemObjectBuilder builder = rootObject.getBuilder();
builder.newInstance(
IBond.class,
builder.newInstance(IAtom.class),
builder.newInstance(IMolecule.class)
);
}

@Test public void testNewBond_IAtom_IAtom_IBond_Order() {
IChemObjectBuilder builder = rootObject.getBuilder();
IBond bond = builder.newInstance(
Expand Down

0 comments on commit 84b2e87

Please sign in to comment.