summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-04-29 15:38:05 +0200
committerPeter Wu <peter@lekensteyn.nl>2016-04-29 15:38:05 +0200
commit358e26f688ffd88144711aa5981b5dc9ec503cd0 (patch)
tree45168ef4e477efba4a1caee51cb8dda2de1801d4 /src
parent548c042b4b203ca20038716f0f12f1968e329ac5 (diff)
downloadRegexTest-358e26f688ffd88144711aa5981b5dc9ec503cd0.tar.gz
Fix match
Do not look for longest match, but for the exact match. Documented at http://www.brics.dk/automaton/doc/dk/brics/automaton/RunAutomaton.html#run%28java.lang.String%29
Diffstat (limited to 'src')
-rw-r--r--src/regex/RegexTest.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/regex/RegexTest.java b/src/regex/RegexTest.java
index d23356a..8776c3f 100644
--- a/src/regex/RegexTest.java
+++ b/src/regex/RegexTest.java
@@ -40,9 +40,9 @@ public class RegexTest {
}
private void check(String input, boolean expectOk) {
- int length = r.run(input, 0);
+ boolean accepted = r.run(input);
System.out.println("Testing input: " + input);
- if (expectOk && length == -1 || !expectOk && length != -1) {
+ if (expectOk && !accepted || !expectOk && accepted) {
throw new RuntimeException("Unexpected result for " + input);
}
}