mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-12450 Promoted TestBoilerplate subclasses to independent classes and applied minor changes to satisfy the ICU4J test code requirements, then include them in the regular test run. Also turned StringBoilerplate to a test case.
X-SVN-Rev: 38703
This commit is contained in:
parent
4a572c0092
commit
6e907382d0
6 changed files with 159 additions and 93 deletions
|
@ -13,6 +13,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -34,7 +35,9 @@ import com.ibm.icu.text.UnicodeSet;
|
|||
*/
|
||||
public abstract class TestBoilerplate<T> extends TestFmwk {
|
||||
|
||||
public final void TestMain() throws Exception {
|
||||
protected static Random random = new Random(12345);
|
||||
|
||||
protected final void _test() throws Exception {
|
||||
List<T> list = new LinkedList<T>();
|
||||
while (_addTestObject(list)) {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2016, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.translit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.icu.dev.test.TestBoilerplate;
|
||||
|
||||
/**
|
||||
* Moved from UnicodeMapTest
|
||||
*/
|
||||
public class StringBoilerplateTest extends TestBoilerplate<String> {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new StringBoilerplateTest().run(args);
|
||||
}
|
||||
|
||||
public void TestStringBoilerplate() throws Exception {
|
||||
_test();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected boolean _hasSameBehavior(String a, String b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_addTestObject(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected boolean _addTestObject(List<String> list) {
|
||||
if (list.size() > 31) return false;
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.append((char)random.nextInt(0xFF));
|
||||
}
|
||||
list.add(result.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2016, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -29,7 +29,9 @@ public class TestAll extends TestGroup {
|
|||
"RegexUtilitiesTest",
|
||||
"UnicodeMapTest",
|
||||
"ThreadTest",
|
||||
"TestUnicodeProperty"
|
||||
"UnicodeMapBoilerplateTest",
|
||||
"UnicodeSetBoilerplateTest",
|
||||
"StringBoilerplateTest"
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2016, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.translit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.icu.dev.test.TestBoilerplate;
|
||||
import com.ibm.icu.dev.util.UnicodeMap;
|
||||
|
||||
/**
|
||||
* Moved from UnicodeMapTest
|
||||
*/
|
||||
public class UnicodeMapBoilerplateTest extends TestBoilerplate<UnicodeMap> {
|
||||
|
||||
private static String[] TEST_VALUES = {"A", "B", "C", "D", "E", "F"};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new UnicodeMapBoilerplateTest().run(args);
|
||||
}
|
||||
|
||||
public void TestUnicodeMapBoilerplate() throws Exception {
|
||||
_test();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
protected boolean _hasSameBehavior(UnicodeMap a, UnicodeMap b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_addTestObject(java.util.List)
|
||||
*/
|
||||
protected boolean _addTestObject(List<UnicodeMap> list) {
|
||||
if (list.size() > 30) return false;
|
||||
UnicodeMap result = new UnicodeMap();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
int start = random.nextInt(25);
|
||||
String value = TEST_VALUES[random.nextInt(TEST_VALUES.length)];
|
||||
result.put(start, value);
|
||||
}
|
||||
list.add(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,11 +9,9 @@ package com.ibm.icu.dev.test.translit;
|
|||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
@ -25,8 +23,8 @@ import com.ibm.icu.dev.test.TestBoilerplate;
|
|||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.dev.util.UnicodeMap;
|
||||
import com.ibm.icu.dev.util.UnicodeMapIterator;
|
||||
import com.ibm.icu.dev.util.UnicodeMap.EntryRange;
|
||||
import com.ibm.icu.dev.util.UnicodeMapIterator;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.lang.UCharacter;
|
||||
import com.ibm.icu.lang.UProperty;
|
||||
|
@ -374,18 +372,6 @@ public class UnicodeMapTest extends TestFmwk {
|
|||
}
|
||||
}
|
||||
|
||||
public void testBoilerplate() {
|
||||
// check boilerplate
|
||||
List argList = new ArrayList();
|
||||
argList.add("TestMain");
|
||||
if (params.verbose) argList.add("-verbose");
|
||||
String[] args = new String[argList.size()];
|
||||
argList.toArray(args);
|
||||
new UnicodeMapBoilerplate().run(args);
|
||||
// TODO: the following is not being reached
|
||||
new UnicodeSetBoilerplate().run(args);
|
||||
}
|
||||
|
||||
public void TestAUnicodeMap2() {
|
||||
UnicodeMap foo = new UnicodeMap();
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -490,78 +476,4 @@ public class UnicodeMapTest extends TestFmwk {
|
|||
.append(entry.getValue()).append("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static class UnicodeMapBoilerplate extends TestBoilerplate {
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
protected boolean _hasSameBehavior(Object a, Object b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_createTestObject()
|
||||
*/
|
||||
protected boolean _addTestObject(List list) {
|
||||
if (list.size() > 30) return false;
|
||||
UnicodeMap result = new UnicodeMap();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
int start = random.nextInt(25);
|
||||
String value = TEST_VALUES[random.nextInt(TEST_VALUES.length)];
|
||||
result.put(start, value);
|
||||
}
|
||||
list.add(result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static class StringBoilerplate extends TestBoilerplate {
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
protected boolean _hasSameBehavior(Object a, Object b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_createTestObject()
|
||||
*/
|
||||
protected boolean _addTestObject(List list) {
|
||||
if (list.size() > 31) return false;
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.append((char)random.nextInt(0xFF));
|
||||
}
|
||||
list.add(result.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static class UnicodeSetBoilerplate extends TestBoilerplate {
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
protected boolean _hasSameBehavior(Object a, Object b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_createTestObject()
|
||||
*/
|
||||
protected boolean _addTestObject(List list) {
|
||||
if (list.size() > 32) return false;
|
||||
UnicodeSet result = new UnicodeSet();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
result.add(random.nextInt(100));
|
||||
}
|
||||
list.add(result.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2016, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.translit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.icu.dev.test.TestBoilerplate;
|
||||
import com.ibm.icu.text.UnicodeSet;
|
||||
|
||||
/**
|
||||
* Moved from UnicodeMapTest
|
||||
*/
|
||||
public class UnicodeSetBoilerplateTest extends TestBoilerplate<UnicodeSet> {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new UnicodeSetBoilerplateTest().run(args);
|
||||
}
|
||||
|
||||
public void TestUnicodeSetBoilerplate() throws Exception {
|
||||
_test();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_hasSameBehavior(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected boolean _hasSameBehavior(UnicodeSet a, UnicodeSet b) {
|
||||
// we are pretty confident in the equals method, so won't bother with this right now.
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.dev.test.TestBoilerplate#_addTestObject(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected boolean _addTestObject(List<UnicodeSet> list) {
|
||||
if (list.size() > 32) return false;
|
||||
UnicodeSet result = new UnicodeSet();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
result.add(random.nextInt(100));
|
||||
}
|
||||
list.add(result);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue