Parser { Bond decideBond(final Bond a, final Bond b, int pos, CharBuffer buffer) throws InvalidSmilesException { if (a == b) return a; else if (a == Bond.IMPLICIT) return b; else if (b == Bond.IMPLICIT) return a; if (strict || a.inverse() != b) throw new InvalidSmilesException("Ring closure bonds did not match, '" + a + "'!='" + b + "':" + InvalidSmilesException.display(buffer, pos-buffer.position, lastBondPos-buffer.position)); warnings.add("Ignored invalid Cis/Trans on ring closure, should flip:" + InvalidSmilesException.display(buffer, pos-buffer.position, lastBondPos-buffer.position)); return Bond.IMPLICIT; } Parser(CharBuffer buffer, boolean strict);   Parser(String str); List<Edge> getEdges(LocalArrangement localArrangement, int u); int[] getAlleneCarriers(int focus); Collection<? extends String> getWarnings();  }
@Test(expected = InvalidSmilesException.class) public void ringBondMismatch() throws InvalidSmilesException { new Parser("").decideBond(Bond.SINGLE, Bond.DOUBLE, -1, CharBuffer.fromString("")); }
@Test public void ringBondDecision() throws InvalidSmilesException { assertThat(new Parser("").decideBond(Bond.DOUBLE, Bond.DOUBLE, -1, CharBuffer.fromString("")), is(Bond.DOUBLE)); assertThat(new Parser("").decideBond(Bond.DOUBLE, Bond.IMPLICIT, -1, CharBuffer.fromString("")), is(Bond.DOUBLE)); assertThat(new Parser("").decideBond(Bond.IMPLICIT, Bond.DOUBLE, -1, CharBuffer.fromString("")), is(Bond.DOUBLE)); }