}
Random r = new Random(1);
for (int i = 0; i < 10000; i++) {
String p1 = paths.get(r.nextInt(paths.size()));
String p2 = paths.get(r.nextInt(paths.size()));
PathRestriction r1 = PathRestriction.values()[r.nextInt(PathRestriction.values().length)];
PathRestriction r2 = PathRestriction.values()[r.nextInt(PathRestriction.values().length)];
Filter f1 = new Filter(null);
f1.restrictPath(p1, r1);
Filter f2 = new Filter(null);
f2.restrictPath(p2, r2);
Filter fc = new Filter(null);
fc.restrictPath(p1, r1);
fc.restrictPath(p2, r2);
int tooMany = 0;
for (String p : paths) {
boolean expected = f1.testPath(p) && f2.testPath(p);
boolean got = fc.testPath(p);
if (expected == got) {
// good
} else if (expected && !got) {
fc = new Filter(null);
fc.restrictPath(p1, r1);
fc.restrictPath(p2, r2);
fail("not matched: " + p1 + "/" + r1.name() + " && " + p2 + "/" + r2.name());
} else {
// not great, but not a problem
tooMany++;
}
}
if (tooMany > 3) {
fail("too many matches: " + p1 + "/" + r1.name() + " && " + p2 + "/" + r2.name() + " superfluous: " + tooMany);
}
}
}