]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_8_1_1/main/tests/framework/src/com/ibm/icu/dev/test/sample/ModuleTestSample.java
Added flags.
[Dictionary.git] / jars / icu4j-4_8_1_1 / main / tests / framework / src / com / ibm / icu / dev / test / sample / ModuleTestSample.java
1 /**
2  *******************************************************************************
3  * Copyright (C) 2001-2006, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.dev.test.sample;
8
9 import com.ibm.icu.dev.test.ModuleTest;
10
11 public class ModuleTestSample extends ModuleTest {
12     public static void main(String[] args) throws Exception {
13     new ModuleTestSample().run(args);
14     }
15     ModuleTestSample(){
16         super("com/ibm/icu/dev/data/testdata/", "Test");
17     }
18
19     // standard loop, settings and cases
20 //    public void Test01() {
21 //    while (nextSettings()) {
22 //        logln("--------");
23 //        logln("String: " + settings.getString("aString"));
24 //        if (settings.isDefined("anInt")) {
25 //        logln("Int: " + settings.getInt("anInt"));
26 //        }
27 //        logln("Boolean: " + settings.getBoolean("aBoolean"));
28 //
29 //        while (nextCase()) {
30 //        logln("  ----");
31 //        logln("  StringArray: " + printArray(testcase.getStringArray("aStringArray")));
32 //        logln("  IntArray: " + printArray(testcase.getIntArray("anIntArray")));
33 //        logln("  BooleanArray: " + printArray(testcase.getBooleanArray("aBooleanArray")));
34 //        }
35 //    }
36 //    }
37 //
38 //    // loop with just cases
39 //    public void Test02() {
40 //    while (nextCase()) {
41 //        logln("----");
42 //        logln("String: " + testcase.getString("aString"));
43 //        logln("Int: " + testcase.getInt("anInt"));
44 //        logln("Boolean: " + testcase.getBoolean("aBoolean"));
45 //    }
46 //    }
47
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
54 //    }
55 //    return;
56     }
57
58     // no data, ModuleTest should not allow this to execute by default
59     public void Test04() {
60     errln("Test04 should not execute!");
61     }
62
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);
67     }
68
69     // no data, but override of validateMethod allows it to execute
70     public void Test05() {
71     logln("Test05 executed.");
72     }
73
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()) {
78 //        logln("----");
79 //        logln("isGood: " + testcase.getString("IsGood"));
80 //        logln("  Data: " + testcase.getInt("Data"));
81 //    }
82 //    }
83 //
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 + "'");
93 //        } else {
94 //            logln("'" + factor + "' is a factor of '" + value + "'");
95 //        }
96 //        }
97 //    }
98 //    }
99
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);
107 //    }
108 //    }
109 //
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]);
119 //                    break;
120 //                }
121 //            }
122 //        }
123 //    }
124                 
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) {
129         if (i != 0) {
130         buf.append(",");
131         }
132         buf.append(" " + a[i]);
133     }
134     buf.append(" }");
135     return buf.toString();
136     }
137
138     String printArray(int[] a) {
139     StringBuffer buf = new StringBuffer("int[] {");
140     for (int i = 0; i < a.length; ++i) {
141         if (i != 0) {
142         buf.append(",");
143         }
144         buf.append(" " + a[i]);
145     }
146     buf.append(" }");
147     return buf.toString();
148     }
149
150     String printArray(boolean[] a) {
151     StringBuffer buf = new StringBuffer("boolean[] {");
152     for (int i = 0; i < a.length; ++i) {
153         if (i != 0) {
154         buf.append(",");
155         }
156         buf.append(" " + a[i]);
157     }
158     buf.append(" }");
159     return buf.toString();
160     }
161
162     /* (non-Javadoc)
163      * @see com.ibm.icu.dev.test.ModuleTest#processModules()
164      */
165     protected void processModules() {
166         // TODO Auto-generated method stub
167         
168     }
169 }