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