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