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