1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/********************************************************************
4 * COPYRIGHT:
5 * Copyright (c) 1998-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8
9/**
10 * MajorTestLevel is the top level test class for everything in the directory "IntlWork".
11 */
12
13/***********************************************************************
14* Modification history
15* Date        Name        Description
16* 02/14/2001  synwee      Release collation for testing.
17***********************************************************************/
18
19#include "unicode/utypes.h"
20#include "unicode/localpointer.h"
21#include "itmajor.h"
22
23#include "itutil.h"
24#include "tscoll.h"
25#include "itformat.h"
26#include "ittrans.h"
27#include "itrbbi.h"
28#include "itrbnf.h"
29#include "itrbnfp.h"
30#include "itrbnfrt.h"
31#include "itspoof.h"
32#include "normconf.h"
33#include "regextst.h"
34#include "tstnorm.h"
35#include "canittst.h"
36#include "icusvtst.h"
37#include "testidna.h"
38#include "convtest.h"
39#include "csdetest.h"
40
41extern IntlTest *createBiDiConformanceTest();
42
43#define CASE_SUITE(id, suite) case id:                  \
44                          name = #suite;                \
45                          if(exec) {                    \
46                              logln(#suite "---");      \
47                              suite test;               \
48                              callTest(test, par);      \
49                          }                             \
50                          break
51
52void MajorTestLevel::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
53{
54    switch (index) {
55        case 0: name = "utility";
56                if (exec) {
57                    logln("TestSuite Utilities---"); logln();
58                    IntlTestUtilities test;
59                    callTest( test, par );
60                }
61                break;
62
63        case 1: name = "normalize";
64#if !UCONFIG_NO_NORMALIZATION
65                if (exec) {
66                    logln("TestSuite Normalize---"); logln();
67                    IntlTestNormalize test;
68                    callTest( test, par );
69                }
70#endif
71                break;
72
73        case 2: name = "collate";
74#if !UCONFIG_NO_COLLATION
75                if (exec) {
76                    logln("TestSuite Collator---"); logln();
77                    IntlTestCollator test;
78                    callTest( test, par );
79                }
80#endif
81                break;
82
83        case 3: name = "regex";
84#if !UCONFIG_NO_REGULAR_EXPRESSIONS
85                if (exec) {
86                    logln("TestSuite Regex---"); logln();
87                    RegexTest test;
88                    callTest( test, par );
89                }
90#endif
91                break;
92
93        case 4: name = "format";
94#if !UCONFIG_NO_FORMATTING
95                if (exec) {
96                    logln("TestSuite Format---"); logln();
97                    IntlTestFormat test;
98                    callTest( test, par );
99                }
100#endif
101                break;
102
103        case 5: name = "translit";
104#if !UCONFIG_NO_TRANSLITERATION
105                if (exec) {
106                    logln("TestSuite Transliterator---"); logln();
107                    IntlTestTransliterator test;
108                    callTest( test, par );
109                }
110#endif
111                break;
112
113        case 6: name = "rbbi";
114#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_REGULAR_EXPRESSIONS
115                if (exec) {
116                    logln("TestSuite RuleBasedBreakIterator---"); logln();
117                    IntlTestRBBI test;
118                    callTest( test, par );
119                }
120#endif
121                break;
122        case 7: name = "rbnf";
123#if !UCONFIG_NO_FORMATTING
124                if (exec) {
125                    logln("TestSuite RuleBasedNumberFormat----"); logln();
126                    IntlTestRBNF test;
127                    callTest(test, par);
128                }
129#endif
130                break;
131        case 8: name = "rbnfrt";
132#if !UCONFIG_NO_FORMATTING
133                if (exec) {
134                    logln("TestSuite RuleBasedNumberFormat RT----"); logln();
135                    RbnfRoundTripTest test;
136                    callTest(test, par);
137                }
138#endif
139                break;
140
141        case 9: name = "icuserv";
142#if !UCONFIG_NO_SERVICE
143                if (exec) {
144                    logln("TestSuite ICUService---"); logln();
145                    ICUServiceTest test;
146                    callTest(test, par);
147                }
148#endif
149                break;
150        case 10: name = "idna";
151#if !UCONFIG_NO_IDNA  && !UCONFIG_NO_TRANSLITERATION
152            if(exec){
153                logln("TestSuite IDNA----"); logln();
154                TestIDNA test;
155                callTest(test,par);
156            }
157#endif
158            break;
159        case 11: name = "convert";
160#if !UCONFIG_NO_LEGACY_CONVERSION
161                if (exec) {
162                    logln("TestSuite Conversion---"); logln();
163                    ConversionTest test;
164                    callTest( test, par );
165                }
166#endif
167                break;
168
169            case 12: name = "rbnfp";
170#if !UCONFIG_NO_FORMATTING
171                if (exec) {
172                    logln("TestSuite RuleBasedNumberParse ----"); logln();
173                    IntlTestRBNFParse test;
174                    callTest(test, par);
175                }
176#endif
177                break;
178
179            case 13: name = "csdet";
180                if (exec) {
181                    logln("TestSuite CharsetDetection---"); logln();
182                    CharsetDetectionTest test;
183                    callTest(test, par);
184                }
185
186                break;
187
188            case 14:
189#if !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_NORMALIZATION && !UCONFIG_NO_FILE_IO
190                name = "spoof";
191                if (exec) {
192                    logln("TestSuite SpoofDetection---"); logln();
193                    IntlTestSpoof test;
194                    callTest(test, par);
195                }
196#else
197                name = "skip";
198#endif
199                break;
200
201            case 15: name = "bidi";
202                if (exec) {
203                    logln("TestSuite bidi---"); logln();
204                    LocalPointer<IntlTest> test(createBiDiConformanceTest());
205                    callTest(*test, par);
206                }
207
208                break;
209
210        default: name = ""; break;
211    }
212
213
214}
215
216void IntlTestNormalize::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
217{
218    if(exec) logln("TestSuite Normalize:");
219#if UCONFIG_NO_NORMALIZATION
220    name="";
221#else
222    switch (index) {
223        CASE_SUITE(0, BasicNormalizerTest);
224        CASE_SUITE(1, NormalizerConformanceTest); // this takes a long time
225        CASE_SUITE(2, CanonicalIteratorTest);
226        default:
227            name="";
228            break;
229    }
230#endif
231}
232