}
public void checkModification(UnicodeSet original, boolean isFrozen) {
main:
for (int i = 0; ;++i) {
UnicodeSet test = (UnicodeSet) (isFrozen ? original.clone() : original.cloneAsThawed());
boolean gotException = true;
boolean checkEquals = true;
try {
switch(i) {
case 0: test.add(0); break;
case 1: test.add(0,1); break;
case 2: test.add("a"); break;
case 3: List a = new ArrayList(); a.add("a"); test.addAll(a); break;
case 4: test.addAll("ab"); break;
case 5: test.addAll(new UnicodeSet("[ab]")); break;
case 6: test.applyIntPropertyValue(0,0); break;
case 7: test.applyPattern("[ab]"); break;
case 8: test.applyPattern("[ab]", true); break;
case 9: test.applyPattern("[ab]", 0); break;
case 10: test.applyPropertyAlias("hex","true"); break;
case 11: test.applyPropertyAlias("hex", "true", null); break;
case 12: test.closeOver(UnicodeSet.CASE); break;
case 13: test.compact(); checkEquals = false; break;
case 14: test.complement(0); break;
case 15: test.complement(0,0); break;
case 16: test.complement("ab"); break;
case 17: test.complementAll("ab"); break;
case 18: test.complementAll(new UnicodeSet("[ab]")); break;
case 19: test.remove(' '); break;
case 20: test.remove(' ','a'); break;
case 21: test.remove(" "); break;
case 22: test.removeAll(" a"); break;
case 23: test.removeAll(new UnicodeSet("[\\ a]")); break;
case 24: test.retain(' '); break;
case 25: test.retain(' ','a'); break;
case 26: test.retain(" "); break;
case 27: test.retainAll(" a"); break;
case 28: test.retainAll(new UnicodeSet("[\\ a]")); break;
case 29: test.set(0,1); break;
case 30: test.set(new UnicodeSet("[ab]")); break;
default: continue main; // so we don't keep having to change the endpoint, and gaps are not skipped.
case 35: return;
}
gotException = false;
} catch (UnsupportedOperationException e) {
// do nothing
}
if (isFrozen && !gotException) errln(i + ") attempt to modify frozen object didn't result in an exception");
if (!isFrozen && gotException) errln(i + ") attempt to modify thawed object did result in an exception");
if (checkEquals) {
if (test.equals(original)) {
if (!isFrozen) errln(i + ") attempt to modify thawed object didn't change the object");
} else { // unequal
if (isFrozen) errln(i + ") attempt to modify frozen object changed the object");
}
}