ICU-11447 add toString. Just an override of existing API, so not an API change.
X-SVN-Rev: 37918
This commit is contained in:
parent
2c7e3cfe4d
commit
1fc1ceab55
@ -1569,6 +1569,33 @@ public class SpoofChecker {
|
||||
checks = 0;
|
||||
position = 0;
|
||||
}
|
||||
|
||||
private static final String[] NAMES = {
|
||||
"SINGLE_SCRIPT_CONFUSABLE",
|
||||
"MIXED_SCRIPT_CONFUSABLE",
|
||||
"WHOLE_SCRIPT_CONFUSABLE",
|
||||
"ANY_CASE",
|
||||
"RESTRICTION_LEVEL",
|
||||
"INVISIBLE",
|
||||
"CHAR_LIMIT",
|
||||
"MIXED_NUMBERS"
|
||||
};
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "checks: " + getCheckNames(checks)
|
||||
+ ", numerics: " + numerics.toPattern(false)
|
||||
+ ", position: " + position
|
||||
+ ", restrictionLevel: " + restrictionLevel
|
||||
;
|
||||
}
|
||||
|
||||
static String getCheckNames(int check) {
|
||||
return check >= 1 && check < (1 << NAMES.length) ? NAMES[(int)Math.round(Math.log10(check)/Math.log10(2))] : null;
|
||||
} // might be better way to do this, but just threw it together quickly.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -795,4 +795,20 @@ public class SpoofCheckerTest extends TestFmwk {
|
||||
errln(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void TestCheckResultToString11447() {
|
||||
Object[][] tests = {
|
||||
{"1", "[0]"},
|
||||
{"१", "[०]"},
|
||||
{"1१", "[0०]"},
|
||||
{"١۱", "[٠۰]"},
|
||||
};
|
||||
CheckResult checkResult = new CheckResult();
|
||||
SpoofChecker sc = new SpoofChecker.Builder()
|
||||
.setChecks(-1)
|
||||
.build();
|
||||
sc.failsChecks("1१", checkResult);
|
||||
assertTrue("CheckResult: ", checkResult.toString().contains("MIXED_NUMBERS"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user