Skip to content

Commit

Permalink
Corner case detected in testing - don't parse a charge symbol on it's…
Browse files Browse the repository at this point in the history
… own as valid.
  • Loading branch information
johnmay committed Sep 12, 2015
1 parent 1d978ee commit 775910d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -189,8 +189,8 @@ static boolean parse(String label, List<String> tokens) {
i++;
}
}
// a charge token
else if (i == st) {
// a charge token, only if it's after some other parts
else if (i == st && st > 0) {
c = normDash(label.charAt(i));
if (c == '-' || c == '+') {
i++;
Expand Down
Expand Up @@ -157,4 +157,14 @@ public void formatOPO3H2() {
assertThat(texts.get(3).text, is("2"));
assertThat(texts.get(3).style, is(-1));
}

@Test
public void parseChargeOnly() {
assertFalse(AbbreviationLabel.parse("+", new ArrayList<String>()));
}

@Test
public void parseNumberOnly() {
assertFalse(AbbreviationLabel.parse("1", new ArrayList<String>()));
}
}

0 comments on commit 775910d

Please sign in to comment.