}
}
private void checkMatch(CharsetDetector det, String testString, String encoding, String language, String id) throws Exception
{
CharsetMatch m = det.detect();
String decoded;
if (! m.getName().equals(encoding)) {
errln(id + ": encoding detection failure - expected " + encoding + ", got " + m.getName());
return;
}
String charsetMatchLanguage = m.getLanguage();
if ((language != null && !charsetMatchLanguage.equals(language))
|| (language == null && charsetMatchLanguage != null)
|| (language != null && charsetMatchLanguage == null))
{
errln(id + ", " + encoding + ": language detection failure - expected " + language + ", got " + m.getLanguage());
}
if (encoding.startsWith("UTF-32")) {
return;
}
decoded = m.getString();
if (! testString.equals(decoded)) {
errln(id + ", " + encoding + ": getString() didn't return the original string!");
}
decoded = stringFromReader(m.getReader());
if (! testString.equals(decoded)) {
errln(id + ", " + encoding + ": getReader() didn't yield the original string!");
}
}