Skip to content

Commit

Permalink
Empty targets are also a problem for the substructure search. Simple …
Browse files Browse the repository at this point in the history
…checks avoids the infinite loop.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Mar 8, 2014
1 parent c1f7b2d commit d9ef27f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -61,7 +61,8 @@ final class StateStream implements Iterator<int[]> {
StateStream(final State state) {
this.state = state;
this.stack = new CandidateStack(state.nMax());
this.next = state.nMax() == 0 ? null : findNext(); // first-mapping
this.next = state.nMax() == 0 || state.mMax() == 0 ? null
: findNext(); // first-mapping
}

/** @inheritDoc */
Expand Down
Expand Up @@ -331,6 +331,11 @@ public abstract class SubstructureTest {
assertMismatch(smi(""),
smi("[H][H]"));
}

@Test public void emptyTarget() throws Exception {
assertMismatch(smi("[H][H]"),
smi(""));
}

void assertMatch(IAtomContainer query, IAtomContainer target, int count) {
assertThat(query.getProperty(TITLE)
Expand Down

0 comments on commit d9ef27f

Please sign in to comment.