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