]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/nmfmtrt.h
ICU-57149.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / nmfmtrt.h
CommitLineData
b75a7d8f
A
1/********************************************************************
2 * COPYRIGHT:
2ca993e8 3 * Copyright (c) 1997-2015, International Business Machines Corporation and
b75a7d8f
A
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7#ifndef _NUMBERFORMATROUNDTRIPTEST_
8#define _NUMBERFORMATROUNDTRIPTEST_
9
10#include "unicode/utypes.h"
11
12#if !UCONFIG_NO_FORMATTING
13
14#include "unicode/numfmt.h"
15#include "unicode/fmtable.h"
16#include "intltest.h"
b75a7d8f
A
17
18/**
19 * Performs round-trip tests for NumberFormat
20 **/
21class NumberFormatRoundTripTest : public IntlTest {
22
23 // IntlTest override
24 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
25public:
26
27 static UBool verbose;
28 static UBool STRING_COMPARE;
29 static UBool EXACT_NUMERIC_COMPARE;
2ca993e8 30 static UBool DEBUG_VAR;
b75a7d8f
A
31 static double MAX_ERROR;
32 static double max_numeric_error;
33 static double min_numeric_error;
34
35
36 void start(void);
37
38 void test(NumberFormat *fmt);
39 void test(NumberFormat *fmt, double value);
40 void test(NumberFormat *fmt, int32_t value);
41 void test(NumberFormat *fmt, const Formattable& value);
42
43 static double randomDouble(double range);
44 static double proportionalError(const Formattable& a, const Formattable& b);
45 static UnicodeString& typeOf(const Formattable& n, UnicodeString& result);
46 static UnicodeString& escape(UnicodeString& s);
47
48 static inline UBool
49 isDouble(const Formattable& n)
50 { return (n.getType() == Formattable::kDouble); }
51
52 static inline UBool
53 isLong(const Formattable& n)
54 { return (n.getType() == Formattable::kLong); }
55
56 /*
57 * Return a random uint32_t
58 **/
374ca955 59 static uint32_t randLong();
b75a7d8f
A
60
61 /**
62 * Return a random double 0 <= x < 1.0
63 **/
64 static double randFraction()
65 {
66 return (double)randLong() / (double)0xFFFFFFFF;
67 }
68
69protected:
729e4ab9 70 UBool failure(UErrorCode status, const char* msg, UBool possibleDataError=FALSE);
b75a7d8f
A
71
72};
73
74#endif /* #if !UCONFIG_NO_FORMATTING */
75
76#endif // _NUMBERFORMATROUNDTRIPTEST_
77//eof