ICU-12986 parameterizes long running unit test to split it into shorter unit test runs.
X-SVN-Rev: 40534
This commit is contained in:
parent
07cc118310
commit
d6cc900c42
@ -0,0 +1,66 @@
|
||||
// © 2017 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
package com.ibm.icu.dev.test.translit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
|
||||
/***********************************************************************
|
||||
|
||||
This test class uses JUnit parametrization to iterate over all
|
||||
transliterators and to execute a sample operation.
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class TransliteratorInstantiateAllTest extends TestFmwk {
|
||||
private String testTransliteratorID;
|
||||
|
||||
public TransliteratorInstantiateAllTest /*InstantiationTest*/(String t) {
|
||||
this.testTransliteratorID = t;
|
||||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection testData() {
|
||||
ArrayList<String> allTranslitIDs = new ArrayList<String>();
|
||||
|
||||
for (Enumeration e = Transliterator.getAvailableIDs(); e.hasMoreElements(); ) {
|
||||
allTranslitIDs.add((String) e.nextElement());
|
||||
}
|
||||
|
||||
return allTranslitIDs;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestInstantiation() {
|
||||
Transliterator t = null;
|
||||
|
||||
try {
|
||||
t = Transliterator.getInstance(testTransliteratorID);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
errln("FAIL: " + testTransliteratorID);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
if (t != null) {
|
||||
// Test toRules
|
||||
String rules = null;
|
||||
try {
|
||||
rules = t.toRules(true);
|
||||
Transliterator.createFromRules("x", rules, Transliterator.FORWARD);
|
||||
} catch (IllegalArgumentException ex2) {
|
||||
errln("FAIL: " + "ID" + ".toRules() => bad rules: " +
|
||||
rules);
|
||||
throw ex2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -170,62 +170,14 @@ public class TransliteratorTest extends TestFmwk {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TestInstantiation() {
|
||||
long ms = System.currentTimeMillis();
|
||||
String ID;
|
||||
for (Enumeration e = Transliterator.getAvailableIDs(); e.hasMoreElements(); ) {
|
||||
ID = (String) e.nextElement();
|
||||
if (ID.equals("Latin-Han/definition")) {
|
||||
System.out.println("\nTODO: disabling Latin-Han/definition check for now: fix later");
|
||||
continue;
|
||||
}
|
||||
Transliterator t = null;
|
||||
try {
|
||||
t = Transliterator.getInstance(ID);
|
||||
// This is only true for some subclasses
|
||||
// // We should get a new instance if we try again
|
||||
// Transliterator t2 = Transliterator.getInstance(ID);
|
||||
// if (t != t2) {
|
||||
// logln("OK: " + Transliterator.getDisplayName(ID) + " (" + ID + "): " + t);
|
||||
// } else {
|
||||
// errln("FAIL: " + ID + " returned identical instances");
|
||||
// t = null;
|
||||
// }
|
||||
} catch (IllegalArgumentException ex) {
|
||||
errln("FAIL: " + ID);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// if (t.getFilter() != null) {
|
||||
// errln("Fail: Should never have filter on transliterator unless we started with one: " + ID + ", " + t.getFilter());
|
||||
// }
|
||||
|
||||
if (t != null) {
|
||||
// Now test toRules
|
||||
String rules = null;
|
||||
try {
|
||||
rules = t.toRules(true);
|
||||
|
||||
Transliterator.createFromRules("x", rules, Transliterator.FORWARD);
|
||||
} catch (IllegalArgumentException ex2) {
|
||||
errln("FAIL: " + ID + ".toRules() => bad rules: " +
|
||||
rules);
|
||||
throw ex2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now test the failure path
|
||||
public void TestInstantiationError() {
|
||||
try {
|
||||
ID = "<Not a valid Transliterator ID>";
|
||||
String ID = "<Not a valid Transliterator ID>";
|
||||
Transliterator t = Transliterator.getInstance(ID);
|
||||
errln("FAIL: " + ID + " returned " + t);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
logln("OK: Bogus ID handled properly");
|
||||
}
|
||||
|
||||
ms = System.currentTimeMillis() - ms;
|
||||
logln("Elapsed time: " + ms + " ms");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user