]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/tsnmfmt.h
ICU-400.42.tar.gz
[apple/icu.git] / icuSources / test / intltest / tsnmfmt.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2003, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7 #ifndef _INTLTESTNUMBERFORMAT
8 #define _INTLTESTNUMBERFORMAT
9
10
11 #include "unicode/utypes.h"
12
13 #if !UCONFIG_NO_FORMATTING
14
15 #include "unicode/numfmt.h"
16 #include "unicode/locid.h"
17 #include "intltest.h"
18
19
20 /**
21 * This test does round-trip testing (format -> parse -> format -> parse -> etc.) of
22 * NumberFormat.
23 */
24 class IntlTestNumberFormat: public IntlTest {
25 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
26
27 private:
28
29 /**
30 * call tryIt with many variations, called by testLocale
31 **/
32 void testFormat(/* char* par */);
33 /**
34 * perform tests using aNumber and fFormat, called in many variations
35 **/
36 void tryIt(double aNumber);
37 /**
38 * perform tests using aNumber and fFormat, called in many variations
39 **/
40 void tryIt(int32_t aNumber);
41 /**
42 * test NumberFormat::getAvailableLocales
43 **/
44 void testAvailableLocales(/* char* par */);
45 /**
46 * call testLocale for all locales
47 **/
48 void monsterTest(/* char *par */);
49 /**
50 * call testFormat for currency, percent and plain number instances
51 **/
52 void testLocale(/* char *par, */const Locale& locale, const UnicodeString& localeName);
53
54 NumberFormat* fFormat;
55 UErrorCode fStatus;
56 Locale fLocale;
57
58 public:
59
60 virtual ~IntlTestNumberFormat();
61
62 /*
63 * Return a random double that isn't too large.
64 */
65 static double getSafeDouble(double smallerThanMax);
66
67 /*
68 * Return a random double
69 **/
70 static double randDouble();
71
72 /*
73 * Return a random uint32_t
74 **/
75 static uint32_t randLong();
76
77 /**
78 * Return a random double 0 <= x < 1.0
79 **/
80 static double randFraction()
81 {
82 return (double)randLong() / (double)0xFFFFFFFF;
83 }
84
85 };
86
87 #endif /* #if !UCONFIG_NO_FORMATTING */
88
89 #endif