mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
Regex: Test Pattern#split(String)
The particular pattern we use to test it is used in ImgLib2, based on this answer on stackoverflow: http://stackoverflow.com/a/279337 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
8ab10a6953
commit
b4c768b101
@ -44,6 +44,16 @@ public class Regex {
|
||||
expect(!matcher.find());
|
||||
}
|
||||
|
||||
private static void expectSplit(String regex, String string,
|
||||
String... list)
|
||||
{
|
||||
String[] array = Pattern.compile(regex).split(string);
|
||||
expect(array.length == list.length);
|
||||
for (int i = 0; i < list.length; ++ i) {
|
||||
expect(list[i].equals(array[i]));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
expectMatch("a(bb)?a", "abba");
|
||||
expectNoMatch("a(bb)?a", "abbba");
|
||||
@ -69,5 +79,7 @@ public class Regex {
|
||||
expectMatch("\\x4A", "J");
|
||||
expectMatch("\\x61", "a");
|
||||
expectMatch("\\078", "\0078");
|
||||
expectSplit("(?<=\\w)(?=\\W)|(?<=\\W)(?=\\w)", "a + b * x",
|
||||
"a", " + ", "b", " * ", "x");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user