2 *******************************************************************************
3 * Copyright (C) 2001-2006, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
7 package com.ibm.icu.dev.test.sample;
9 import com.ibm.icu.dev.test.ModuleTest;
11 public class ModuleTestSample extends ModuleTest {
12 public static void main(String[] args) throws Exception {
13 new ModuleTestSample().run(args);
16 super("com/ibm/icu/dev/data/testdata/", "Test");
19 // standard loop, settings and cases
20 // public void Test01() {
21 // while (nextSettings()) {
23 // logln("String: " + settings.getString("aString"));
24 // if (settings.isDefined("anInt")) {
25 // logln("Int: " + settings.getInt("anInt"));
27 // logln("Boolean: " + settings.getBoolean("aBoolean"));
29 // while (nextCase()) {
31 // logln(" StringArray: " + printArray(testcase.getStringArray("aStringArray")));
32 // logln(" IntArray: " + printArray(testcase.getIntArray("anIntArray")));
33 // logln(" BooleanArray: " + printArray(testcase.getBooleanArray("aBooleanArray")));
38 // // loop with just cases
39 // public void Test02() {
40 // while (nextCase()) {
42 // logln("String: " + testcase.getString("aString"));
43 // logln("Int: " + testcase.getInt("anInt"));
44 // logln("Boolean: " + testcase.getBoolean("aBoolean"));
48 // no cases, just uses info for test
49 public void Test03() {
50 // DataMap info = testInfo();
51 // if (info != null) {
52 //// logln(info.getString(TestDataModule.DESCRIPTION)); // standard
53 // logln(info.getString("Extra")); // test-specific
58 // no data, ModuleTest should not allow this to execute by default
59 public void Test04() {
60 errln("Test04 should not execute!");
63 // special override of validateMethod allows Test05
64 // to execute even though it has no data in the module
65 protected boolean validateMethod(String methodName) {
66 return methodName.equals("Test05") ? true : super.validateMethod(methodName);
69 // no data, but override of validateMethod allows it to execute
70 public void Test05() {
71 logln("Test05 executed.");
74 // // The test data contains an error in the third case. When getInt("Data") is
75 // // executed the error is logged and iteration stops.
76 // public void Test06() {
77 // while (nextCase()) {
79 // logln("isGood: " + testcase.getString("IsGood"));
80 // logln(" Data: " + testcase.getInt("Data"));
84 // // The test using the data reports an error, which also automatically stops iteration.
85 // public void Test07() {
86 // while (nextSettings()) {
87 // int value = settings.getInt("Value");
88 // while (nextCase()) {
89 // int factor = testcase.getInt("Factor");
90 // float result = (float)value / factor;
91 // if (result != (int)result) {
92 // errln("the number '" + factor + "' is not a factor of the number '" + value + "'");
94 // logln("'" + factor + "' is a factor of '" + value + "'");
100 // // The number of data elements is incorrect
101 // public void Test08() {
102 // while (nextCase()) {
103 // int one = testcase.getInt("One");
104 // int two = testcase.getInt("Two");
105 // int three = testcase.getInt("Three");
106 // logln("got: " + one + ", " + two + ", " + three);
110 // public void Test09() {
111 // while (nextCase()) {
112 // int radix = testcase.getInt("Radix");
113 // int[] pow = testcase.getIntArray("Power");
114 // int[] val = testcase.getIntArray("Value");
115 // logln("radix: " + radix + " pow: " + printArray(pow) + " val: " + printArray(val));
116 // for (int i = 0; i < pow.length; ++i) {
117 // if (val[i] != (int)Math.pow(radix, pow[i])) {
118 // errln("radix: " + radix + " to power " + pow[i] + " != " + val[i]);
125 // utility print functions to display the data from the resource
126 String printArray(String[] a) {
127 StringBuffer buf = new StringBuffer("String[] {");
128 for (int i = 0; i < a.length; ++i) {
132 buf.append(" " + a[i]);
135 return buf.toString();
138 String printArray(int[] a) {
139 StringBuffer buf = new StringBuffer("int[] {");
140 for (int i = 0; i < a.length; ++i) {
144 buf.append(" " + a[i]);
147 return buf.toString();
150 String printArray(boolean[] a) {
151 StringBuffer buf = new StringBuffer("boolean[] {");
152 for (int i = 0; i < a.length; ++i) {
156 buf.append(" " + a[i]);
159 return buf.toString();
163 * @see com.ibm.icu.dev.test.ModuleTest#processModules()
165 protected void processModules() {
166 // TODO Auto-generated method stub