1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/********************************************************************
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * COPYRIGHT:
327f654740f2a26ad62a5c155af9199af9e69b889claireho * Copyright (c) 1997-2010, International Business Machines Corporation and
4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * others. All Rights Reserved.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ********************************************************************/
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * IntlTest is a base class for tests.
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdio.h>
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <string.h>
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <assert.h>
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdarg.h>
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <stdlib.h>
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/unistr.h"
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/ures.h"
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/smpdtfmt.h"
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/ucnv.h"
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uclean.h"
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/timezone.h"
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/curramt.h"
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/putil.h"
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "intltest.h"
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "caltztst.h"
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "itmajor.h"
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cstring.h"
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "umutex.h"
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uassert.h"
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cmemory.h"
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uoptions.h"
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
3827f654740f2a26ad62a5c155af9199af9e69b889claireho#include "putilimp.h" // for uprv_getRawUTCtime()
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/locid.h"
4027f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/ctest.h" // for str_timeDelta
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef XP_MAC_CONSOLE
43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include <console.h>
44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "Files.h"
45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic char* _testDataPath=NULL;
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Static list of errors found
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic UnicodeString errorList;
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//-----------------------------------------------------------------------------
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//convenience classes to ease porting code that uses the Java
55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//string-concatenation operator (moved from findword test by rtg)
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// [LIU] Just to get things working
58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUCharToUnicodeString(UChar c)
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return UnicodeString(c); }
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// [rtg] Just to get things working
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruoperator+(const UnicodeString& left,
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      long num)
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[64];    // nos changed from 10 to 64
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char danger = 'p';  // guard against overrunning the buffer (rtg)
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sprintf(buffer, "%ld", num);
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    assert(danger == 'p');
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return left + buffer;
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruoperator+(const UnicodeString& left,
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      unsigned long num)
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[64];    // nos changed from 10 to 64
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char danger = 'p';  // guard against overrunning the buffer (rtg)
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sprintf(buffer, "%lu", num);
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    assert(danger == 'p');
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return left + buffer;
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruInt64ToUnicodeString(int64_t num)
91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[64];    // nos changed from 10 to 64
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char danger = 'p';  // guard against overrunning the buffer (rtg)
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef U_WINDOWS
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sprintf(buffer, "%I64d", num);
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sprintf(buffer, "%lld", (long long)num);
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    assert(danger == 'p');
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return buffer;
103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// [LIU] Just to get things working
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruoperator+(const UnicodeString& left,
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru      double num)
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[64];   // was 32, made it arbitrarily bigger (rtg)
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char danger = 'p'; // guard against overrunning the buffer (rtg)
112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // IEEE floating point has 52 bits of mantissa, plus one assumed bit
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //  53*log(2)/log(10) = 15.95
115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // so there is no need to show more than 16 digits. [alan]
116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    sprintf(buffer, "%.17g", num);
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    assert(danger == 'p');
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return left + buffer;
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
12627f654740f2a26ad62a5c155af9199af9e69b889claireho * Return a string display for this, without surrounding braces.
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString _toString(const Formattable& f) {
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString s;
130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (f.getType()) {
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kDate:
132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            UErrorCode status = U_ZERO_ERROR;
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            SimpleDateFormat fmt(status);
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (U_SUCCESS(status)) {
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                FieldPosition pos;
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fmt.format(f.getDate(), s, pos);
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                s.insert(0, "Date:");
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                s = UnicodeString("Error creating date format]");
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kDouble:
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        s = UnicodeString("double:") + f.getDouble();
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kLong:
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        s = UnicodeString("long:") + f.getLong();
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kInt64:
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        s = UnicodeString("int64:") + Int64ToUnicodeString(f.getInt64());
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kString:
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        f.getString(s);
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        s.insert(0, "String:");
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case Formattable::kArray:
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            int32_t i, n;
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            const Formattable* array = f.getArray(n);
163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            s.insert(0, UnicodeString("Array:"));
164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            UnicodeString delim(", ");
165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            for (i=0; i<n; ++i) {
166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (i > 0) {
167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    s.append(delim);
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                s = s + _toString(array[i]);
170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
17327f654740f2a26ad62a5c155af9199af9e69b889claireho    case Formattable::kObject: {
17427f654740f2a26ad62a5c155af9199af9e69b889claireho        const CurrencyAmount* c = dynamic_cast<const CurrencyAmount*>(f.getObject());
17527f654740f2a26ad62a5c155af9199af9e69b889claireho        if (c != NULL) {
17627f654740f2a26ad62a5c155af9199af9e69b889claireho            s = _toString(c->getNumber()) + " " + UnicodeString(c->getISOCurrency());
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            s = UnicodeString("Unknown UObject");
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
18127f654740f2a26ad62a5c155af9199af9e69b889claireho    }
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    default:
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        s = UnicodeString("Unknown Formattable type=") + (int32_t)f.getType();
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return s;
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Originally coded this as operator+, but that makes the expression
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * + char* ambiguous. - liu
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString toString(const Formattable& f) {
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString s((UChar)91/*[*/);
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    s.append(_toString(f));
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    s.append((UChar)0x5d/*]*/);
197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return s;
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// useful when operator+ won't cooperate
203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString toString(int32_t n) {
204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return UnicodeString() + (long)n;
205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// stephen - cleaned up 05/05/99
208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, char num)
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (long)num; }
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, short num)
211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (long)num; }
212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, int num)
213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (long)num; }
214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, unsigned char num)
215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (unsigned long)num; }
216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, unsigned short num)
217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (unsigned long)num; }
218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, unsigned int num)
219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (unsigned long)num; }
220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString operator+(const UnicodeString& left, float num)
221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ return left + (double)num; }
222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//------------------
224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Append a hex string to the target
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString&
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest::appendHex(uint32_t number,
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            int32_t digits,
229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            UnicodeString& target)
230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const UChar digitString[] = {
232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0
234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }; /* "0123456789ABCDEF" */
235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (digits)
237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 8:
239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >> 28) & 0xF];
240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 7:
241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >> 24) & 0xF];
242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 6:
243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >> 20) & 0xF];
244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 5:
245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >> 16) & 0xF];
246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 4:
247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >> 12) & 0xF];
248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 3:
249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >>  8) & 0xF];
250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 2:
251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >>  4) & 0xF];
252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    case 1:
253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += digitString[(number >>  0) & 0xF];
254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        break;
255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    default:
256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        target += "**";
257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return target;
259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
26127f654740f2a26ad62a5c155af9199af9e69b889clairehostatic inline UBool isPrintable(UChar32 c) {
26227f654740f2a26ad62a5c155af9199af9e69b889claireho    return c <= 0x7E && (c >= 0x20 || c == 9 || c == 0xA || c == 0xD);
26327f654740f2a26ad62a5c155af9199af9e69b889claireho}
26427f654740f2a26ad62a5c155af9199af9e69b889claireho
265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Replace nonprintable characters with unicode escapes
266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString&
267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest::prettify(const UnicodeString &source,
268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru           UnicodeString &target)
269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target.remove();
273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target += "\"";
274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < source.length(); )
276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UChar32 ch = source.char32At(i);
27827f654740f2a26ad62a5c155af9199af9e69b889claireho        i += U16_LENGTH(ch);
279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
28027f654740f2a26ad62a5c155af9199af9e69b889claireho        if (!isPrintable(ch))
281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (ch <= 0xFFFF) {
283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                target += "\\u";
284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                appendHex(ch, 4, target);
285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                target += "\\U";
287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                appendHex(ch, 8, target);
288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else
291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            target += ch;
293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target += "\"";
297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return target;
299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Replace nonprintable characters with unicode escapes
302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString
303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest::prettify(const UnicodeString &source, UBool parseBackslash)
304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t i;
306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString target;
307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target.remove();
308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target += "\"";
309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (i = 0; i < source.length();)
311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UChar32 ch = source.char32At(i);
31327f654740f2a26ad62a5c155af9199af9e69b889claireho        i += U16_LENGTH(ch);
314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
31527f654740f2a26ad62a5c155af9199af9e69b889claireho        if (!isPrintable(ch))
316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (parseBackslash) {
318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                // If we are preceded by an odd number of backslashes,
319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                // then this character has already been backslash escaped.
320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                // Delete a backslash.
321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                int32_t backslashCount = 0;
322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                for (int32_t j=target.length()-1; j>=0; --j) {
323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    if (target.charAt(j) == (UChar)92) {
324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        ++backslashCount;
325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    } else {
326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                        break;
327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    }
328b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
329b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if ((backslashCount % 2) == 1) {
330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    target.truncate(target.length() - 1);
331b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (ch <= 0xFFFF) {
334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                target += "\\u";
335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                appendHex(ch, 4, target);
336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            } else {
337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                target += "\\U";
338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                appendHex(ch, 8, target);
339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else
342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        {
343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            target += ch;
344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
346b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
347b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    target += "\"";
348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return target;
350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
352b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*  IntlTest::setICU_DATA  - if the ICU_DATA environment variable is not already
353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       set, try to deduce the directory in which ICU was built,
354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       and set ICU_DATA to "icu/source/data" in that location.
355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       The intent is to allow the tests to have a good chance
356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       of running without requiring that the user manually set
357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       ICU_DATA.  Common data isn't a problem, since it is
358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       picked up via a static (build time) reference, but the
359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                       tests dynamically load some data.
360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::setICU_DATA() {
362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *original_ICU_DATA = getenv("ICU_DATA");
363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (original_ICU_DATA != NULL && *original_ICU_DATA != 0) {
365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /*  If the user set ICU_DATA, don't second-guess the person. */
366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return;
367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // U_TOPBUILDDIR is set by the makefiles on UNIXes when building cintltst and intltst
370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              to point to the top of the build hierarchy, which may or
371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              may not be the same as the source directory, depending on
372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              the configure options used.  At any rate,
373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              set the data path to the built data from this directory.
374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              The value is complete with quotes, so it can be used
375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              as-is as a string constant.
376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if defined (U_TOPBUILDDIR)
378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        static char env_string[] = U_TOPBUILDDIR "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        u_setDataDirectory(env_string);
381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return;
382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Use #else so we don't get compiler warnings due to the return above.
386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* On Windows, the file name obtained from __FILE__ includes a full path.
388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             This file is "wherever\icu\source\test\cintltst\cintltst.c"
389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             Change to    "wherever\icu\source\data"
390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char p[sizeof(__FILE__) + 10];
393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char *pBackSlash;
394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        int i;
395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcpy(p, __FILE__);
397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* We want to back over three '\' chars.                            */
398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /*   Only Windows should end up here, so looking for '\' is safe.   */
399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (i=1; i<=3; i++) {
400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (pBackSlash != NULL) {
402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                *pBackSlash = 0;        /* Truncate the string at the '\'   */
403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (pBackSlash != NULL) {
407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            /* We found and truncated three names from the path.
408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             *  Now append "source\data" and set the environment
409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru             */
410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            u_setDataDirectory(p);     /*  p is "ICU_DATA=wherever\icu\source\data"    */
412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            /* __FILE__ on MSVC7 does not contain the directory */
416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            u_setDataDirectory(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return;
418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* No location for the data dir was identifiable.
423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *   Add other fallbacks for the test data location here if the need arises
424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//--------------------------------------------------------------------------------------
429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const int32_t indentLevel_offset = 3;
431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const char delim = '/';
432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest* IntlTest::gTest = NULL;
434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic int32_t execCount = 0;
436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_log( UnicodeString message )
438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
440b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->log( message );
441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_logln( UnicodeString message )
444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->logln( message );
447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_logln( void )
450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->logln();
453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_info( UnicodeString message )
456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->info( message );
459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_infoln( UnicodeString message )
462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->infoln( message );
465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
467b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_infoln( void )
468b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->infoln();
471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_err()
474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->err();
477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_err( UnicodeString message )
480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->err( message );
483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_errln( UnicodeString message )
486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->errln( message );
489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_dataerr( UnicodeString message )
492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->dataerr( message );
495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid it_dataerrln( UnicodeString message )
498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (IntlTest::gTest)
500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::gTest->dataerrln( message );
501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest::IntlTest()
504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    caller = NULL;
506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    testPath = NULL;
507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    LL_linestart = TRUE;
508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    errorCount = 0;
509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    dataErrorCount = 0;
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    verbose = FALSE;
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    no_err_msg = FALSE;
512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    warn_on_missing_data = FALSE;
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    quick = FALSE;
514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    leaks = FALSE;
51550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    threadCount = 1;
516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    testoutfp = stdout;
517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    LL_indentlevel = indentLevel_offset;
518b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    numProps = 0;
51927f654740f2a26ad62a5c155af9199af9e69b889claireho    strcpy(basePath, "/");
520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::setCaller( IntlTest* callingTest )
523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    caller = callingTest;
525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (caller) {
526c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        warn_on_missing_data = caller->warn_on_missing_data;
527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        verbose = caller->verbose;
528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        no_err_msg = caller->no_err_msg;
529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        quick = caller->quick;
530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testoutfp = caller->testoutfp;
531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        LL_indentlevel = caller->LL_indentlevel + indentLevel_offset;
532b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        numProps = caller->numProps;
533b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        for (int32_t i = 0; i < numProps; i++) {
534b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru            proplines[i] = caller->proplines[i];
535b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        }
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::callTest( IntlTest& testToBeCalled, char* par )
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    execCount--; // correct a previously assumed test-exec, as this only calls a subtest
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    testToBeCalled.setCaller( this );
54327f654740f2a26ad62a5c155af9199af9e69b889claireho    strcpy(testToBeCalled.basePath, this->basePath );
54427f654740f2a26ad62a5c155af9199af9e69b889claireho    UBool result = testToBeCalled.runTest( testPath, par, testToBeCalled.basePath );
54527f654740f2a26ad62a5c155af9199af9e69b889claireho    strcpy(testToBeCalled.basePath, this->basePath ); // reset it.
54627f654740f2a26ad62a5c155af9199af9e69b889claireho    return result;
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::setPath( char* pathVal )
550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->testPath = pathVal;
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::setVerbose( UBool verboseVal )
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval = this->verbose;
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->verbose = verboseVal;
558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::setWarnOnMissingData( UBool warn_on_missing_dataVal )
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval = this->warn_on_missing_data;
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->warn_on_missing_data = warn_on_missing_dataVal;
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::setNoErrMsg( UBool no_err_msgVal )
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval = this->no_err_msg;
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->no_err_msg = no_err_msgVal;
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::setQuick( UBool quickVal )
576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval = this->quick;
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->quick = quickVal;
579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::setLeaks( UBool leaksVal )
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval = this->leaks;
585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->leaks = leaksVal;
586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
58950294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoint32_t IntlTest::setThreadCount( int32_t count )
59050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho{
59150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t rval = this->threadCount;
59250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    this->threadCount = count;
59350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    return rval;
59450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho}
59550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruint32_t IntlTest::getErrors( void )
597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return errorCount;
599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruint32_t IntlTest::getDataErrors( void )
602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return dataErrorCount;
604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
60627f654740f2a26ad62a5c155af9199af9e69b889clairehoUBool IntlTest::runTest( char* name, char* par, char *baseName )
607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool rval;
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char* pos = NULL;
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
61127f654740f2a26ad62a5c155af9199af9e69b889claireho    char* baseNameBuffer = NULL;
61227f654740f2a26ad62a5c155af9199af9e69b889claireho
61327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(baseName == NULL) {
61427f654740f2a26ad62a5c155af9199af9e69b889claireho      baseNameBuffer = (char*)malloc(1024);
61527f654740f2a26ad62a5c155af9199af9e69b889claireho      baseName=baseNameBuffer;
61627f654740f2a26ad62a5c155af9199af9e69b889claireho      strcpy(baseName, "/");
61727f654740f2a26ad62a5c155af9199af9e69b889claireho    }
61827f654740f2a26ad62a5c155af9199af9e69b889claireho
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (name)
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        pos = strchr( name, delim ); // check if name contains path (by looking for '/')
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (pos) {
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testPath = pos+1;   // store subpath for calling subtest
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *pos = 0;       // split into two strings
624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else{
625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        testPath = NULL;
626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!name || (name[0] == 0) || (strcmp(name, "*") == 0)) {
62927f654740f2a26ad62a5c155af9199af9e69b889claireho      rval = runTestLoop( NULL, par, baseName );
630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else if (strcmp( name, "LIST" ) == 0) {
632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        this->usage();
633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        rval = TRUE;
634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else{
63627f654740f2a26ad62a5c155af9199af9e69b889claireho      rval = runTestLoop( name, par, baseName );
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (pos)
640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *pos = delim;  // restore original value at pos
64127f654740f2a26ad62a5c155af9199af9e69b889claireho    if(baseNameBuffer!=NULL) {
64227f654740f2a26ad62a5c155af9199af9e69b889claireho      free(baseNameBuffer);
64327f654740f2a26ad62a5c155af9199af9e69b889claireho    }
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// call individual tests, to be overriden to call implementations
648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // to be overriden by a method like:
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /*
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    switch (index) {
653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        case 0: name = "First Test"; if (exec) FirstTest( par ); break;
654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        case 1: name = "Second Test"; if (exec) SecondTest( par ); break;
655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        default: name = ""; break;
656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    */
658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    this->errln("*** runIndexedTest needs to be overriden! ***");
659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    name = ""; exec = exec; index = index; par = par;
660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
66327f654740f2a26ad62a5c155af9199af9e69b889clairehoUBool IntlTest::runTestLoop( char* testname, char* par, char *baseName )
664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t    index = 0;
666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char*   name;
667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool  run_this_test;
668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t    lastErrorCount;
669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool  rval = FALSE;
670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool   lastTestFailed;
671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
67227f654740f2a26ad62a5c155af9199af9e69b889claireho    if(baseName == NULL) {
67327f654740f2a26ad62a5c155af9199af9e69b889claireho      printf("ERROR: baseName can't be null.\n");
67427f654740f2a26ad62a5c155af9199af9e69b889claireho      return FALSE;
67527f654740f2a26ad62a5c155af9199af9e69b889claireho    } else {
67627f654740f2a26ad62a5c155af9199af9e69b889claireho      if ((char *)this->basePath != baseName) {
67727f654740f2a26ad62a5c155af9199af9e69b889claireho        strcpy(this->basePath, baseName);
67827f654740f2a26ad62a5c155af9199af9e69b889claireho      }
67927f654740f2a26ad62a5c155af9199af9e69b889claireho    }
68027f654740f2a26ad62a5c155af9199af9e69b889claireho
68127f654740f2a26ad62a5c155af9199af9e69b889claireho    char * saveBaseLoc = baseName+strlen(baseName);
68227f654740f2a26ad62a5c155af9199af9e69b889claireho
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IntlTest* saveTest = gTest;
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    gTest = this;
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    do {
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        this->runIndexedTest( index, FALSE, name, par );
68750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        if (strcmp(name,"skip") == 0) {
68850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            run_this_test = FALSE;
68950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho        } else {
69050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            if (!name || (name[0] == 0))
69150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                break;
69250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            if (!testname) {
69350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                run_this_test = TRUE;
69450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            }else{
69550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                run_this_test = (UBool) (strcmp( name, testname ) == 0);
69650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            }
697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (run_this_test) {
699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            lastErrorCount = errorCount;
700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            execCount++;
70127f654740f2a26ad62a5c155af9199af9e69b889claireho            char msg[256];
70227f654740f2a26ad62a5c155af9199af9e69b889claireho            sprintf(msg, "%s {", name);
70327f654740f2a26ad62a5c155af9199af9e69b889claireho            LL_message(msg, TRUE);
70427f654740f2a26ad62a5c155af9199af9e69b889claireho            UDate timeStart = uprv_getRawUTCtime();
70527f654740f2a26ad62a5c155af9199af9e69b889claireho            strcpy(saveBaseLoc,name);
70627f654740f2a26ad62a5c155af9199af9e69b889claireho            strcat(saveBaseLoc,"/");
70727f654740f2a26ad62a5c155af9199af9e69b889claireho
708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            this->runIndexedTest( index, TRUE, name, par );
70927f654740f2a26ad62a5c155af9199af9e69b889claireho
71027f654740f2a26ad62a5c155af9199af9e69b889claireho            UDate timeStop = uprv_getRawUTCtime();
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            rval = TRUE; // at least one test has been called
71227f654740f2a26ad62a5c155af9199af9e69b889claireho            char secs[256];
71327f654740f2a26ad62a5c155af9199af9e69b889claireho            sprintf(secs, "%f", (timeStop-timeStart)/1000.0);
71427f654740f2a26ad62a5c155af9199af9e69b889claireho
71527f654740f2a26ad62a5c155af9199af9e69b889claireho
71627f654740f2a26ad62a5c155af9199af9e69b889claireho            strcpy(saveBaseLoc,name);
71727f654740f2a26ad62a5c155af9199af9e69b889claireho
71827f654740f2a26ad62a5c155af9199af9e69b889claireho
71927f654740f2a26ad62a5c155af9199af9e69b889claireho            ctest_xml_testcase(baseName, name, secs, (lastErrorCount!=errorCount)?"err":NULL);
72027f654740f2a26ad62a5c155af9199af9e69b889claireho
72127f654740f2a26ad62a5c155af9199af9e69b889claireho
72227f654740f2a26ad62a5c155af9199af9e69b889claireho            saveBaseLoc[0]=0; /* reset path */
72327f654740f2a26ad62a5c155af9199af9e69b889claireho
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (lastErrorCount == errorCount) {
72527f654740f2a26ad62a5c155af9199af9e69b889claireho                sprintf( msg, "   } OK:   %s ", name );
72627f654740f2a26ad62a5c155af9199af9e69b889claireho                str_timeDelta(msg+strlen(msg),timeStop-timeStart);
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                lastTestFailed = FALSE;
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }else{
72927f654740f2a26ad62a5c155af9199af9e69b889claireho                sprintf(msg,  "   } ERRORS (%li) in %s", (long)(errorCount-lastErrorCount), name);
73027f654740f2a26ad62a5c155af9199af9e69b889claireho                str_timeDelta(msg+strlen(msg),timeStop-timeStart);
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                for(int i=0;i<LL_indentlevel;i++) {
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    errorList += " ";
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errorList += name;
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                errorList += "\n";
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                lastTestFailed = TRUE;
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            LL_indentlevel -= 3;
740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (lastTestFailed) {
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                LL_message( "", TRUE);
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            LL_message( msg, TRUE);
744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (lastTestFailed) {
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                LL_message( "", TRUE);
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            LL_indentlevel += 3;
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        index++;
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }while(name);
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
75227f654740f2a26ad62a5c155af9199af9e69b889claireho    *saveBaseLoc = 0;
75327f654740f2a26ad62a5c155af9199af9e69b889claireho
754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    gTest = saveTest;
755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return rval;
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Adds given string to the log if we are in verbose mode.
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::log( const UnicodeString &message )
763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( verbose ) {
765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        LL_message( message, FALSE );
766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
769b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
770b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Adds given string to the log if we are in verbose mode. Adds a new line to
771b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* the given message.
772b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
773b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::logln( const UnicodeString &message )
774b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
775b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( verbose ) {
776b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        LL_message( message, TRUE );
777b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
778b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
779b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
780b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::logln( void )
781b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
782b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( verbose ) {
783b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        LL_message( "", TRUE );
784b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
785b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
786b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
787b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
788b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Unconditionally adds given string to the log.
789b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::info( const UnicodeString &message )
791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  LL_message( message, FALSE );
793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Unconditionally adds given string to the log. Adds a new line to
797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* the given message.
798b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
799b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::infoln( const UnicodeString &message )
800b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
801b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  LL_message( message, TRUE );
802b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
803b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
804b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::infoln( void )
805b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
806b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru  LL_message( "", TRUE );
807b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
808b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
809b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruint32_t IntlTest::IncErrorCount( void )
810b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
811b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    errorCount++;
812b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (caller) caller->IncErrorCount();
813b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return errorCount;
814b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
815b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
816b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruint32_t IntlTest::IncDataErrorCount( void )
817b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
818b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    dataErrorCount++;
819b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (caller) caller->IncDataErrorCount();
820b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return dataErrorCount;
821b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
822b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
823b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::err()
824b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
825b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IncErrorCount();
826b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
827b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
828b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::err( const UnicodeString &message )
829b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
830b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IncErrorCount();
831b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!no_err_msg) LL_message( message, FALSE );
832b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
833b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
834b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::errln( const UnicodeString &message )
835b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
836b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IncErrorCount();
837b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!no_err_msg) LL_message( message, TRUE );
838b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
839b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
840b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::dataerr( const UnicodeString &message )
841b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
842b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IncDataErrorCount();
843b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
844b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!warn_on_missing_data) {
845b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IncErrorCount();
846b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
847b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
848b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!no_err_msg) LL_message( message, FALSE );
849b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
850b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
851b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::dataerrln( const UnicodeString &message )
852b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
853b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    IncDataErrorCount();
8546d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    UnicodeString msg;
855b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!warn_on_missing_data) {
856b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IncErrorCount();
8576d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        msg = message;
8586d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    } else {
8596d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        msg = UnicodeString("[DATA] " + message);
860b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
861b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
8626d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    if (!no_err_msg) LL_message( msg + " - (Are you missing data?)", TRUE );
8636d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru}
8646d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru
8656d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queruvoid IntlTest::errcheckln(UErrorCode status, const UnicodeString &message ) {
8666d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    if (status == U_FILE_ACCESS_ERROR || status == U_MISSING_RESOURCE_ERROR) {
8676d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln(message);
8686d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    } else {
8696d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errln(message);
8706d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    }
871b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
872b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
873b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* convenience functions that include sprintf formatting */
874b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::log(const char *fmt, ...)
875b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
876b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
877b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
878b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
879b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
880b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* sprintf it just to make sure that the information is valid */
881b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
882b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
883b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( verbose ) {
884b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        log(UnicodeString(buffer, ""));
885b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
886b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
887b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
888b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::logln(const char *fmt, ...)
889b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
890b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
891b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
892b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
893b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
894b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* sprintf it just to make sure that the information is valid */
895b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
896b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
897b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( verbose ) {
898b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(UnicodeString(buffer, ""));
899b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
900b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
901b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
902b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* convenience functions that include sprintf formatting */
903b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::info(const char *fmt, ...)
904b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
905b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
906b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
907b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
908b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
909b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* sprintf it just to make sure that the information is valid */
910b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
911b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
912b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    info(UnicodeString(buffer, ""));
913b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
914b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
915b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::infoln(const char *fmt, ...)
916b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
917b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
918b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
919b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
920b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
921b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* sprintf it just to make sure that the information is valid */
922b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
923b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
924b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    infoln(UnicodeString(buffer, ""));
925b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
926b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
927b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::err(const char *fmt, ...)
928b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
929b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
930b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
931b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
932b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
933b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
934b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
935b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    err(UnicodeString(buffer, ""));
936b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
937b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
938b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::errln(const char *fmt, ...)
939b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
940b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
941b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
942b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
943b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
944b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
945b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
946b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    errln(UnicodeString(buffer, ""));
947b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
948b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
949b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::dataerrln(const char *fmt, ...)
950b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
951b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[4000];
952b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_list ap;
953b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
954b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_start(ap, fmt);
955b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    vsprintf(buffer, fmt, ap);
956b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    va_end(ap);
957b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    dataerrln(UnicodeString(buffer, ""));
958b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
959b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
9606d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queruvoid IntlTest::errcheckln(UErrorCode status, const char *fmt, ...)
9616d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru{
9626d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    char buffer[4000];
9636d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    va_list ap;
9646d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru
9656d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    va_start(ap, fmt);
9666d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    vsprintf(buffer, fmt, ap);
9676d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    va_end(ap);
9686d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru
9696d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    if (status == U_FILE_ACCESS_ERROR || status == U_MISSING_RESOURCE_ERROR) {
9706d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        dataerrln(UnicodeString(buffer, ""));
9716d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    } else {
9726d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        errln(UnicodeString(buffer, ""));
9736d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru    }
9746d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru}
9756d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru
976b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::printErrors()
977b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
978b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     IntlTest::LL_message(errorList, TRUE);
979b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
980b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
981b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::LL_message( UnicodeString message, UBool newline )
982b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
983b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // string that starts with a LineFeed character and continues
984b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // with spaces according to the current indentation
985b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static const UChar indentUChars[] = {
986b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        '\n',
987b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
988b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
989b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
990b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
991b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
992b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
993b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
994b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
995b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
996b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
997b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
998b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString indent(FALSE, indentUChars, 1 + LL_indentlevel);
999b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1000b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    char buffer[10000];
1001b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t length;
1002b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1003b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // stream out the indentation string first if necessary
1004b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    length = indent.extract(1, indent.length(), buffer, sizeof(buffer));
1005b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (length > 0) {
1006b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fwrite(buffer, sizeof(*buffer), length, (FILE *)testoutfp);
1007b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1008b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1009b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // replace each LineFeed by the indentation string
1010b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    message.findAndReplace(UnicodeString((UChar)'\n'), indent);
1011b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1012b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // stream out the message
1013b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    length = message.extract(0, message.length(), buffer, sizeof(buffer));
1014b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (length > 0) {
1015b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        length = length > 10000 ? 10000 : length;
1016b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fwrite(buffer, sizeof(*buffer), length, (FILE *)testoutfp);
1017b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1018b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1019b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (newline) {
1020b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char newLine = '\n';
1021b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fwrite(&newLine, sizeof(newLine), 1, (FILE *)testoutfp);
1022b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1023b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1024b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // A newline usually flushes the buffer, but
1025b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // flush the message just in case of a core dump.
1026b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fflush((FILE *)testoutfp);
1027b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1028b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1029b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1030b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Print a usage message for this test class.
1031b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/
1032b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid IntlTest::usage( void )
1033b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1034b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool save_verbose = setVerbose( TRUE );
1035b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("Test names:");
1036b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    logln("-----------");
1037b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1038b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t index = 0;
1039b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char* name = NULL;
1040b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    do{
1041b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        this->runIndexedTest( index, FALSE, name );
1042b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (!name) break;
1043b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln(name);
1044b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        index++;
1045b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }while (name && (name[0] != 0));
1046b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    setVerbose( save_verbose );
1047b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1048b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1049b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1050b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// memory leak reporting software will be able to take advantage of the testsuite
1051b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// being run a second time local to a specific method in order to report only actual leaks
1052b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool
1053b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruIntlTest::run_phase2( char* name, char* par ) // supports reporting memory leaks
1054b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1055b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString* strLeak = new UnicodeString("forced leak"); // for verifying purify filter
1056b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    strLeak->append(" for verifying purify filter");
1057b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return this->runTest( name, par );
1058b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1059b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1060b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1061b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if UCONFIG_NO_LEGACY_CONVERSION
1062b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#   define TRY_CNV_1 "iso-8859-1"
1063b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#   define TRY_CNV_2 "ibm-1208"
1064b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
1065b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#   define TRY_CNV_1 "iso-8859-7"
1066b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#   define TRY_CNV_2 "sjis"
1067b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1068b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1069b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruint
1070b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querumain(int argc, char* argv[])
1071b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1072b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool syntax = FALSE;
1073b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool all = FALSE;
1074b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool verbose = FALSE;
1075b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool no_err_msg = FALSE;
1076b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool quick = TRUE;
1077b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool name = FALSE;
1078b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool leaks = FALSE;
1079b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool warnOnMissingData = FALSE;
1080b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool defaultDataFound = FALSE;
108150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int32_t threadCount = 1;
1082b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode errorCode = U_ZERO_ERROR;
1083b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UConverter *cnv = NULL;
1084b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *warnOrErr = "Failure";
1085b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UDate startTime, endTime;
1086b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t diffTime;
1087b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    const char *props[IntlTest::kMaxProps];
1088b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    int32_t nProps = 0;
1089b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1090b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    U_MAIN_INIT_ARGS(argc, argv);
1091b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
109227f654740f2a26ad62a5c155af9199af9e69b889claireho    startTime = uprv_getRawUTCtime();
1093b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1094b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int i = 1; i < argc; ++i) {
1095b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (argv[i][0] == '-') {
1096b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            const char* str = argv[i] + 1;
1097b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (strcmp("verbose", str) == 0 ||
1098b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                strcmp("v", str) == 0)
1099b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                verbose = TRUE;
1100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else if (strcmp("noerrormsg", str) == 0 ||
1101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     strcmp("n", str) == 0)
1102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                no_err_msg = TRUE;
1103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else if (strcmp("exhaustive", str) == 0 ||
1104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     strcmp("e", str) == 0)
1105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                quick = FALSE;
1106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else if (strcmp("all", str) == 0 ||
1107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     strcmp("a", str) == 0)
1108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                all = TRUE;
1109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else if (strcmp("leaks", str) == 0 ||
1110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     strcmp("l", str) == 0)
1111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                leaks = TRUE;
111227f654740f2a26ad62a5c155af9199af9e69b889claireho            else if (strcmp("x", str)==0) {
111327f654740f2a26ad62a5c155af9199af9e69b889claireho              if(++i>=argc) {
111427f654740f2a26ad62a5c155af9199af9e69b889claireho                printf("* Error: '-x' option requires an argument. usage: '-x outfile.xml'.\n");
111527f654740f2a26ad62a5c155af9199af9e69b889claireho                syntax = TRUE;
111627f654740f2a26ad62a5c155af9199af9e69b889claireho              }
111727f654740f2a26ad62a5c155af9199af9e69b889claireho              if(ctest_xml_setFileName(argv[i])) { /* set the name */
111827f654740f2a26ad62a5c155af9199af9e69b889claireho                return 1; /* error */
111927f654740f2a26ad62a5c155af9199af9e69b889claireho              }
112027f654740f2a26ad62a5c155af9199af9e69b889claireho            } else if (strcmp("w", str) == 0) {
1121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              warnOnMissingData = TRUE;
1122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              warnOrErr = "WARNING";
1123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
112450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            else if (strncmp("threads:", str, 8) == 0) {
112550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                threadCount = atoi(str + 8);
112650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho            }
1127b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru            else if (strncmp("prop:", str, 5) == 0) {
1128b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                if (nProps < IntlTest::kMaxProps) {
1129b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                    props[nProps] = str + 5;
1130b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                }
1131b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                nProps++;
1132b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru            }
1133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else {
1134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                syntax = TRUE;
1135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }else{
1137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            name = TRUE;
1138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!all && !name) {
1142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        all = TRUE;
1143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else if (all && name) {
1144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        syntax = TRUE;
1145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (syntax) {
1148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout,
1149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### Syntax:\n"
1150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### IntlTest [-option1 -option2 ...] [testname1 testname2 ...] \n"
115150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                "### \n"
115250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                "### Options are: verbose (v), all (a), noerrormsg (n), \n"
115327f654740f2a26ad62a5c155af9199af9e69b889claireho                "### exhaustive (e), leaks (l), -x xmlfile.xml, prop:<propery>=<value>, \n"
115450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                "### threads:<threadCount> (Mulithreading must first be \n"
115550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                "###     enabled otherwise this will be ignored. \n"
115650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho                "###     The default thread count is 1.),\n"
1157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### (Specify either -all (shortcut -a) or a test name). \n"
1158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### -all will run all of the tests.\n"
1159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### \n"
1160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### To get a list of the test names type: intltest LIST \n"
1161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### To run just the utility tests type: intltest utility \n"
1162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### \n"
1163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### Test names can be nested using slashes (\"testA/subtest1\") \n"
1164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### For example to list the utility tests type: intltest utility/LIST \n"
1165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### To run just the Locale test type: intltest utility/LocaleTest \n"
1166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### \n"
1167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### A parameter can be specified for a test by appending '@' and the value \n"
1168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "### to the testname. \n\n");
1169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return 1;
1170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1172b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    if (nProps > IntlTest::kMaxProps) {
1173b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        fprintf(stdout, "### Too many properties.  Exiting.\n");
1174b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
1175b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
1176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool all_tests_exist = TRUE;
1177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    MajorTestLevel major;
1178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    major.setVerbose( verbose );
1179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    major.setNoErrMsg( no_err_msg );
1180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    major.setQuick( quick );
1181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    major.setLeaks( leaks );
118250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    major.setThreadCount( threadCount );
1183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    major.setWarnOnMissingData( warnOnMissingData );
1184b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    for (int32_t i = 0; i < nProps; i++) {
1185b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        major.setProperty(props[i]);
1186b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
118727f654740f2a26ad62a5c155af9199af9e69b889claireho
118827f654740f2a26ad62a5c155af9199af9e69b889claireho
1189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "-----------------------------------------------\n");
1190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, " IntlTest (C++) Test Suite for                 \n");
1191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   International Components for Unicode %s\n", U_ICU_VERSION);
119227f654740f2a26ad62a5c155af9199af9e69b889claireho
119327f654740f2a26ad62a5c155af9199af9e69b889claireho
1194b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    {
1195b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru	const char *charsetFamily = "Unknown";
1196b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        int32_t voidSize = (int32_t)sizeof(void*);
1197b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        int32_t bits = voidSize * 8;
1198b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        if(U_CHARSET_FAMILY==U_ASCII_FAMILY) {
1199b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru           charsetFamily="ASCII";
1200b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        } else if(U_CHARSET_FAMILY==U_EBCDIC_FAMILY) {
1201b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru           charsetFamily="EBCDIC";
1202b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        }
1203b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        fprintf(stdout,
1204b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                    "   Bits: %d, Byte order: %s, Chars: %s\n",
1205b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                     bits, U_IS_BIG_ENDIAN?"Big endian":"Little endian",
1206b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                     charsetFamily);
1207b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
1208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "-----------------------------------------------\n");
1209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, " Options:                                       \n");
1210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   all (a)                  : %s\n", (all?               "On" : "Off"));
1211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   Verbose (v)              : %s\n", (verbose?           "On" : "Off"));
1212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   No error messages (n)    : %s\n", (no_err_msg?        "On" : "Off"));
1213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   Exhaustive (e)           : %s\n", (!quick?            "On" : "Off"));
1214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   Leaks (l)                : %s\n", (leaks?             "On" : "Off"));
1215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "   Warn on missing data (w) : %s\n", (warnOnMissingData? "On" : "Off"));
121650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if (ICU_USE_THREADS==0)
121750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    fprintf(stdout, "   Threads                  : Disabled\n");
121850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#else
121950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    fprintf(stdout, "   Threads                  : %d\n", threadCount);
122050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif
1221b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    for (int32_t i = 0; i < nProps; i++) {
1222b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        fprintf(stdout, "   Custom property (prop:)  : %s\n", props[i]);
1223b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
1224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "-----------------------------------------------\n");
1225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* Check whether ICU will initialize without forcing the build data directory into
1227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  the ICU_DATA path.  Success here means either the data dll contains data, or that
1228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  this test program was run with ICU_DATA set externally.  Failure of this check
1229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  is normal when ICU data is not packaged into a shared library.
1230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *
1231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  Whether or not this test succeeds, we want to cleanup and reinitialize
1232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *  with a data path so that data loading from individual files can be tested.
1233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    u_init(&errorCode);
1235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(errorCode)) {
1236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr,
1237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "#### Note:  ICU Init without build-specific setDataDirectory() failed.\n");
1238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        defaultDataFound = FALSE;
1239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
1241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        defaultDataFound = TRUE;
1242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    u_cleanup();
1244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    errorCode = U_ZERO_ERROR;
1245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* Initialize ICU */
1247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!defaultDataFound) {
1248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        IntlTest::setICU_DATA();   // Must set data directory before u_init() is called.
1249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    u_init(&errorCode);
1251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(errorCode)) {
1252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stderr,
1253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "#### ERROR! %s: u_init() failed with status = \"%s\".\n"
1254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "*** Check the ICU_DATA environment variable and \n"
1255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            "*** check that the data files are present.\n", argv[0], u_errorName(errorCode));
1256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if(warnOnMissingData == 0) {
1257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fprintf(stderr, "*** Exiting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
1258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                u_cleanup();
1259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                return 1;
1260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // initial check for the default converter
1265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    errorCode = U_ZERO_ERROR;
1266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    cnv = ucnv_open(0, &errorCode);
1267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(cnv != 0) {
1268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // ok
1269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ucnv_close(cnv);
1270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
1271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout,
1272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** %s! The default converter [%s] cannot be opened.\n"
1273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** Check the ICU_DATA environment variable and\n"
1274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** check that the data files are present.\n",
1275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                warnOrErr, ucnv_getDefaultName());
1276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!warnOnMissingData) {
1277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          fprintf(stdout, "*** Exiting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
1278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          return 1;
1279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // try more data
1283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    cnv = ucnv_open(TRY_CNV_2, &errorCode);
1284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(cnv != 0) {
1285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        // ok
1286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ucnv_close(cnv);
1287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else {
1288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout,
1289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** %s! The converter for " TRY_CNV_2 " cannot be opened.\n"
1290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** Check the ICU_DATA environment variable and \n"
1291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** check that the data files are present.\n", warnOrErr);
1292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!warnOnMissingData) {
1293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          fprintf(stdout, "*** Exiting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
1294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          return 1;
1295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UResourceBundle *rb = ures_open(0, "en", &errorCode);
1299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ures_close(rb);
1300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(U_FAILURE(errorCode)) {
1301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout,
1302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** %s! The \"en\" locale resource bundle cannot be opened.\n"
1303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** Check the ICU_DATA environment variable and \n"
1304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                "*** check that the data files are present.\n", warnOrErr);
1305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(!warnOnMissingData) {
1306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          fprintf(stdout, "*** Exiting.  Use the '-w' option if data files were\n*** purposely removed, to continue test anyway.\n");
1307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru          return 1;
1308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale originalLocale;  // Save the default locale for comparison later on.
1312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
131327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(ctest_xml_init("intltest"))
131427f654740f2a26ad62a5c155af9199af9e69b889claireho      return 1;
131527f654740f2a26ad62a5c155af9199af9e69b889claireho
131627f654740f2a26ad62a5c155af9199af9e69b889claireho
1317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* TODO: Add option to call u_cleanup and rerun tests. */
1318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (all) {
1319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        major.runTest();
1320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (leaks) {
1321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            major.run_phase2( NULL, NULL );
1322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else{
1324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (int i = 1; i < argc; ++i) {
1325b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (argv[i][0] != '-') {
1326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                char* name = argv[i];
1327b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fprintf(stdout, "\n=== Handling test: %s: ===\n", name);
132827f654740f2a26ad62a5c155af9199af9e69b889claireho
132927f654740f2a26ad62a5c155af9199af9e69b889claireho                char baseName[1024];
133027f654740f2a26ad62a5c155af9199af9e69b889claireho                sprintf(baseName, "/%s/", name);
133127f654740f2a26ad62a5c155af9199af9e69b889claireho
1332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                char* parameter = strchr( name, '@' );
1333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (parameter) {
1334b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    *parameter = 0;
1335b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    parameter += 1;
1336b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
1337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                execCount = 0;
133827f654740f2a26ad62a5c155af9199af9e69b889claireho                UBool res = major.runTest( name, parameter, baseName );
1339b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (leaks && res) {
1340b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    major.run_phase2( name, parameter );
1341b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
1342b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                if (!res || (execCount <= 0)) {
1343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    fprintf(stdout, "\n---ERROR: Test doesn't exist: %s!\n", name);
1344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    all_tests_exist = FALSE;
1345b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                }
134627f654740f2a26ad62a5c155af9199af9e69b889claireho            } else if(!strcmp(argv[i],"-x")) {
134727f654740f2a26ad62a5c155af9199af9e69b889claireho              i++;
1348b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1349b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1351b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
135227f654740f2a26ad62a5c155af9199af9e69b889claireho
1353b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1354b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    CalendarTimeZoneTest::cleanup();
1355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    free(_testDataPath);
1358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    _testDataPath = 0;
1359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    Locale lastDefaultLocale;
1361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (originalLocale != lastDefaultLocale) {
1362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        major.errln("FAILURE: A test changed the default locale without resetting it.");
1363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "\n--------------------------------------\n");
1366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (major.getErrors() == 0) {
1367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* Call it twice to make sure that the defaults were reset. */
1368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* Call it before the OK message to verify proper cleanup. */
1369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        u_cleanup();
1370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        u_cleanup();
1371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout, "OK: All tests passed without error.\n");
1373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1374b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (major.getDataErrors() != 0) {
1375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stdout, "\t*WARNING* some data-loading errors were ignored by the -w option.\n");
1376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1377b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }else{
1378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout, "Errors in total: %ld.\n", (long)major.getErrors());
1379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        major.printErrors();
1380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (major.getDataErrors() != 0) {
1383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fprintf(stdout, "\t*Note* some errors are data-loading related. If the data used is not the \n"
1384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    "\tstock ICU data (i.e some have been added or removed), consider using\n"
1385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                    "\tthe '-w' option to turn these errors into warnings.\n");
1386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* Call afterwards to display errors. */
1389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        u_cleanup();
1390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    fprintf(stdout, "--------------------------------------\n");
1393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (execCount <= 0) {
1395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fprintf(stdout, "***** Not all called tests actually exist! *****\n");
1396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
139727f654740f2a26ad62a5c155af9199af9e69b889claireho    endTime = uprv_getRawUTCtime();
1398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    diffTime = (int32_t)(endTime - startTime);
1399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
1400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
1401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
1402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
1403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        (int)(diffTime%U_MILLIS_PER_SECOND));
140427f654740f2a26ad62a5c155af9199af9e69b889claireho
140527f654740f2a26ad62a5c155af9199af9e69b889claireho    if(ctest_xml_fini())
140627f654740f2a26ad62a5c155af9199af9e69b889claireho      return 1;
140727f654740f2a26ad62a5c155af9199af9e69b889claireho
1408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return major.getErrors();
1409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1410b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1411b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruconst char* IntlTest::loadTestData(UErrorCode& err){
1412b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if( _testDataPath == NULL){
1413b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char*      directory=NULL;
1414b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UResourceBundle* test =NULL;
1415b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char* tdpath=NULL;
1416b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        const char* tdrelativepath;
1417b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1418b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if defined (U_TOPBUILDDIR)
1419b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        tdrelativepath = "test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
1420b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        directory = U_TOPBUILDDIR;
1421b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
1422b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
1423b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        directory = pathToDataDirectory();
1424b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1425b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1426b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        tdpath = (char*) malloc(sizeof(char) *(( strlen(directory) * strlen(tdrelativepath)) + 100));
1427b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1428b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1429b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* u_getDataDirectory shoul return \source\data ... set the
1430b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         * directory to ..\source\data\..\test\testdata\out\testdata
1431b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru         */
1432b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcpy(tdpath, directory);
1433b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcat(tdpath, tdrelativepath);
1434b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcat(tdpath,"testdata");
1435b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1436b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        test=ures_open(tdpath, "testtypes", &err);
1437b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1438b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if(U_FAILURE(err)){
1439b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            err = U_FILE_ACCESS_ERROR;
14406d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            it_dataerrln((UnicodeString)"Could not load testtypes.res in testdata bundle with path " + tdpath + (UnicodeString)" - " + u_errorName(err));
1441b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            return "";
1442b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1443b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        ures_close(test);
1444b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        _testDataPath = tdpath;
1445b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return _testDataPath;
1446b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1447b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return _testDataPath;
1448b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1449b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1450b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruconst char* IntlTest::getTestDataPath(UErrorCode& err) {
1451b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return loadTestData(err);
1452b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1453b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1454b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* Returns the path to icu/source/test/testdata/ */
1455b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruconst char *IntlTest::getSourceTestData(UErrorCode& /*err*/) {
1456b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    const char *srcDataDir = NULL;
1457b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef U_TOPSRCDIR
1458b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
1459b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
1460b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
1461b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
1462b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (f) {
1463b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* We're in icu/source/test/intltest/ */
1464b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fclose(f);
1465b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1466b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
1467b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        /* We're in icu/source/test/intltest/Platform/(Debug|Release) */
1468b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
1469b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1470b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1471b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return srcDataDir;
1472b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1473b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1474b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruconst char* IntlTest::fgDataDir = NULL;
1475b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1476b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* returns the path to icu/source/data */
1477b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruconst char *  IntlTest::pathToDataDirectory()
1478b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{
1479b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1480b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if(fgDataDir != NULL) {
1481b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return fgDataDir;
1482b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1483b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1484b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* U_TOPSRCDIR is set by the makefiles on UNIXes when building cintltst and intltst
1485b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              to point to the top of the build hierarchy, which may or
1486b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              may not be the same as the source directory, depending on
1487b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              the configure options used.  At any rate,
1488b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              set the data path to the built data from this directory.
1489b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              The value is complete with quotes, so it can be used
1490b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //              as-is as a string constant.
1491b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    */
1492b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if defined (U_TOPSRCDIR)
1493b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
1494b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        fgDataDir = U_TOPSRCDIR  U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
1495b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1496b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#else
1497b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1498b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    /* On Windows, the file name obtained from __FILE__ includes a full path.
1499b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             This file is "wherever\icu\source\test\cintltst\cintltst.c"
1500b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     *             Change to    "wherever\icu\source\data"
1501b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru     */
1502b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    {
1503b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        static char p[sizeof(__FILE__) + 10];
1504b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        char *pBackSlash;
1505b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        int i;
1506b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1507b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        strcpy(p, __FILE__);
1508b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /* We want to back over three '\' chars.                            */
1509b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        /*   Only Windows should end up here, so looking for '\' is safe.   */
1510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (i=1; i<=3; i++) {
1511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            pBackSlash = strrchr(p, U_FILE_SEP_CHAR);
1512b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (pBackSlash != NULL) {
1513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                *pBackSlash = 0;        /* Truncate the string at the '\'   */
1514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1516b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (pBackSlash != NULL) {
1518b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            /* We found and truncated three names from the path.
1519b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            *  Now append "source\data" and set the environment
1520b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            */
1521b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING );
1522b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            fgDataDir = p;
1523b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1524b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        else {
1525b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            /* __FILE__ on MSVC7 does not contain the directory */
1526b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
1527b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            if (file) {
1528b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fclose(file);
1529b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
1530b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1531b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            else {
1532b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
1533b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            }
1534b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return fgDataDir;
1539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
1543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This is a variant of cintltst/ccolltst.c:CharsToUChars().
154427f654740f2a26ad62a5c155af9199af9e69b889claireho * It converts an invariant-character string into a UnicodeString, with
1545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * unescaping \u sequences.
1546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
154750294ead5e5d23f5bbfed76e00e6b510bd41eee1clairehoUnicodeString CharsToUnicodeString(const char* chars){
154827f654740f2a26ad62a5c155af9199af9e69b889claireho    return UnicodeString(chars, -1, US_INV).unescape();
1549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUnicodeString ctou(const char* chars) {
1552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return CharsToUnicodeString(chars);
1553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define RAND_M  (714025)
1556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define RAND_IA (1366)
1557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define RAND_IC (150889)
1558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic int32_t RAND_SEED;
1560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Returns a uniform random value x, with 0.0 <= x < 1.0.  Use
1563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * with care: Does not return all possible values; returns one of
1564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 714,025 values, uniformly spaced.  However, the period is
1565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * effectively infinite.  See: Numerical Recipes, section 7.1.
1566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param seedp pointer to seed. Set *seedp to any negative value
1568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * to restart the sequence.
1569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querufloat IntlTest::random(int32_t* seedp) {
1571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static int32_t iy, ir[98];
1572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static UBool first=TRUE;
1573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t j;
1574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (*seedp < 0 || first) {
1575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        first = FALSE;
1576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if ((*seedp=(RAND_IC-(*seedp)) % RAND_M) < 0) *seedp = -(*seedp);
1577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        for (j=1;j<=97;++j) {
1578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            *seedp=(RAND_IA*(*seedp)+RAND_IC) % RAND_M;
1579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            ir[j]=(*seedp);
1580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        *seedp=(RAND_IA*(*seedp)+RAND_IC) % RAND_M;
1582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        iy=(*seedp);
1583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    j=(int32_t)(1 + 97.0*iy/RAND_M);
1585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    U_ASSERT(j>=1 && j<=97);
1586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    iy=ir[j];
1587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    *seedp=(RAND_IA*(*seedp)+RAND_IC) % RAND_M;
1588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ir[j]=(*seedp);
1589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return (float) iy/RAND_M;
1590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
1593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Convenience method using a global seed.
1594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querufloat IntlTest::random() {
1596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return random(&RAND_SEED);
1597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic inline UChar toHex(int32_t i) {
1600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return (UChar)(i + (i < 10 ? 0x30 : (0x41 - 10)));
1601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic UnicodeString& escape(const UnicodeString& s, UnicodeString& result) {
1604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    for (int32_t i=0; i<s.length(); ++i) {
1605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UChar c = s[i];
1606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        if (c <= (UChar)0x7F) {
1607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += c;
1608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        } else {
1609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += (UChar)0x5c;
1610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += (UChar)0x75;
1611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += toHex((c >> 12) & 0xF);
1612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += toHex((c >>  8) & 0xF);
1613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += toHex((c >>  4) & 0xF);
1614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru            result += toHex( c        & 0xF);
1615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        }
1616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return result;
1618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define VERBOSE_ASSERTIONS
1621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
16226d5deb12725f146643d443090dfa11b206df528aJean-Baptiste QueruUBool IntlTest::assertTrue(const char* message, UBool condition, UBool quiet, UBool possibleDataError) {
1623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (!condition) {
16246d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        if (possibleDataError) {
16256d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("FAIL: assertTrue() failed: %s", message);
16266d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        } else {
16276d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            errln("FAIL: assertTrue() failed: %s", message);
16286d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        }
1629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else if (!quiet) {
1630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Ok: %s", message);
1631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return condition;
1633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertFalse(const char* message, UBool condition, UBool quiet) {
1636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (condition) {
1637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln("FAIL: assertFalse() failed: %s", message);
1638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    } else if (!quiet) {
1639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln("Ok: %s", message);
1640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return !condition;
1642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
16446d5deb12725f146643d443090dfa11b206df528aJean-Baptiste QueruUBool IntlTest::assertSuccess(const char* message, UErrorCode ec, UBool possibleDataError) {
1645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (U_FAILURE(ec)) {
16466d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        if (possibleDataError) {
16476d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln("FAIL: %s (%s)", message, u_errorName(ec));
1648c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        } else {
16496d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            errcheckln(ec, "FAIL: %s (%s)", message, u_errorName(ec));
1650c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        }
16516d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru
1652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return FALSE;
1653b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return TRUE;
1655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const char* message,
1658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const UnicodeString& expected,
16596d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                             const UnicodeString& actual,
16606d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                             UBool possibleDataError) {
1661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (expected != actual) {
16626d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        if (possibleDataError) {
16636d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            dataerrln((UnicodeString)"FAIL: " + message + "; got " +
16646d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                  prettify(actual) +
16656d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                  "; expected " + prettify(expected));
16666d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        } else {
16676d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru            errln((UnicodeString)"FAIL: " + message + "; got " +
16686d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                  prettify(actual) +
16696d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru                  "; expected " + prettify(expected));
16706d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru        }
1671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return FALSE;
1672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef VERBOSE_ASSERTIONS
1674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
1675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln((UnicodeString)"Ok: " + message + "; got " + prettify(actual));
1676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return TRUE;
1679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const char* message,
1682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const char* expected,
1683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const char* actual) {
1684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (uprv_strcmp(expected, actual) != 0) {
1685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln((UnicodeString)"FAIL: " + message + "; got \"" +
1686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              actual +
1687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              "\"; expected \"" + expected + "\"");
1688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return FALSE;
1689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef VERBOSE_ASSERTIONS
1691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
1692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln((UnicodeString)"Ok: " + message + "; got \"" + actual + "\"");
1693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return TRUE;
1696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const char* message,
1700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const Formattable& expected,
1701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const Formattable& actual) {
1702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    if (expected != actual) {
1703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        errln((UnicodeString)"FAIL: " + message + "; got " +
1704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              toString(actual) +
1705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              "; expected " + toString(expected));
1706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        return FALSE;
1707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifdef VERBOSE_ASSERTIONS
1709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    else {
1710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        logln((UnicodeString)"Ok: " + message + "; got " + toString(actual));
1711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    }
1712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return TRUE;
1714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic char ASSERT_BUF[256];
1718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic const char* extractToAssertBuf(const UnicodeString& message) {
1720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeString buf;
1721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    escape(message, buf);
1722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    buf.extract(0, 0x7FFFFFFF, ASSERT_BUF, sizeof(ASSERT_BUF)-1, 0);
1723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    ASSERT_BUF[sizeof(ASSERT_BUF)-1] = 0;
1724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return ASSERT_BUF;
1725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertTrue(const UnicodeString& message, UBool condition, UBool quiet) {
1728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertTrue(extractToAssertBuf(message), condition, quiet);
1729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertFalse(const UnicodeString& message, UBool condition, UBool quiet) {
1732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertFalse(extractToAssertBuf(message), condition, quiet);
1733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertSuccess(const UnicodeString& message, UErrorCode ec) {
1736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertSuccess(extractToAssertBuf(message), ec);
1737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const UnicodeString& message,
1740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const UnicodeString& expected,
1741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const UnicodeString& actual) {
1742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertEquals(extractToAssertBuf(message), expected, actual);
1743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const UnicodeString& message,
1746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const char* expected,
1747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const char* actual) {
1748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertEquals(extractToAssertBuf(message), expected, actual);
1749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//--------------------------------------------------------------------
1751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Time bomb - allows temporary behavior that expires at a given
1752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//             release
1753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//--------------------------------------------------------------------
1754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::isICUVersionAtLeast(const UVersionInfo x) {
1756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UVersionInfo v;
1757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    u_getVersion(v);
1758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return (uprv_memcmp(v, x, U_MAX_VERSION_LENGTH) >= 0);
1759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_FORMATTING
1762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool IntlTest::assertEquals(const UnicodeString& message,
1763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const Formattable& expected,
1764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                             const Formattable& actual) {
1765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    return assertEquals(extractToAssertBuf(message), expected, actual);
1766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}
1767b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
1768b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
1769b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruvoid IntlTest::setProperty(const char* propline) {
1770b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    if (numProps < kMaxProps) {
1771b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        proplines[numProps] = propline;
1772b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
1773b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    numProps++;
1774b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru}
1775b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
1776b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queruconst char* IntlTest::getProperty(const char* prop) {
1777b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    const char* val = NULL;
1778b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    for (int32_t i = 0; i < numProps; i++) {
1779b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        int32_t plen = uprv_strlen(prop);
1780b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        if ((int32_t)uprv_strlen(proplines[i]) > plen + 1
1781b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                && proplines[i][plen] == '='
1782b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru                && uprv_strncmp(proplines[i], prop, plen) == 0) {
1783b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru            val = &(proplines[i][plen+1]);
1784b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru            break;
1785b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru        }
1786b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    }
1787b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru    return val;
1788b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru}
1789b0ac937921a2c196d8b9da665135bf6ba01a1ccfJean-Baptiste Queru
1790b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
1791b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Hey, Emacs, please set the following:
1792b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1793b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Local Variables:
1794b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * indent-tabs-mode: nil
1795b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * End:
1796b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
1797b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
1798