//------------------------------------------------------------------------ // Everything below here is boilerplate code that makes it possible // to add a new test by simply adding a method to an existing class. //------------------------------------------------------------------------
protected IntlTest() { // Populate testMethods with all the test methods.
Method[] methods = getClass().getDeclaredMethods(); for (Method method : methods) { if (Modifier.isPublic(method.getModifiers())
&& method.getReturnType() == void.class
&& method.getParameterCount() == 0) {
String name = method.getName(); if (name.length() > 4) { if (name.startsWith("Test") || name.startsWith("test")) {
testMethods.put(name, method);
}
}
}
}
}
protectedvoid run(String[] args) throws Exception
{ // Set up the log and reference streams. We use PrintWriters in order to // take advantage of character conversion. The JavaEsc converter will // convert Unicode outside the ASCII range to Java's \\uxxxx notation.
log = new PrintWriter(System.out, true);
// Parse the test arguments. They can be either the flag // "-verbose" or names of test methods. Create a list of // tests to be run.
List<Method> testsToRun = new ArrayList<>(args.length); for (String arg : args) { switch (arg) { case"-verbose":
verbose = true; break; case"-prompt":
prompt = true; break; case"-nothrow":
nothrow = true; break; case"-exitcode":
exitCode = true; break; default:
Method m = testMethods.get(arg); if (m == null) {
System.out.println("Method " + arg + ": not found");
usage(); return;
}
testsToRun.add(m); break;
}
}
// If no test method names were given explicitly, run them all. if (testsToRun.isEmpty()) {
testsToRun.addAll(testMethods.values());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.