]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/intltest.h
ICU-57166.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / intltest.h
index 877499a945f5f096c6340e80d6336f74fdf6ea78..b8793ba889de2517aa5e47e8fe41d562bee89f15 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
- * COPYRIGHT: 
- * Copyright (c) 1997-2014, International Business Machines Corporation and
+ * COPYRIGHT:
+ * Copyright (c) 1997-2016, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
 
 #if U_NO_DEFAULT_INCLUDE_UTF_HEADERS
 /* deprecated  - make tests pass with U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
-#include "unicode/utf_old.h" 
-#endif
-
-/**
- * \def ICU_USE_THREADS
- *
- * Enables multi-threaded testing. Moved here from uconfig.h.
- * Default: enabled
- *
- * This switch used to allow thread support (use of mutexes) to be compiled out of ICU.
- */
-#ifdef ICU_USE_THREADS
-    /* Use the predefined value. */
-#elif defined(APP_NO_THREADS)
-    /* APP_NO_THREADS is an old symbol. We'll honour it if present. */
-#   define ICU_USE_THREADS 0
-#else
-#   define ICU_USE_THREADS 1
+#include "unicode/utf_old.h"
 #endif
 
 U_NAMESPACE_USE
@@ -183,7 +166,7 @@ public:
     /**
      * Replaces isICUVersionAtLeast and isICUVersionBefore
      * log that an issue is known.
-     * Usually used this way:   
+     * Usually used this way:
      * <code>if( ... && logKnownIssue("12345", "some bug")) continue; </code>
      * @param ticket ticket string, "12345" or "cldrbug:1234"
      * @param message optional message string
@@ -247,11 +230,11 @@ public:
     void errcheckln(UErrorCode status, const char *fmt, ...);
 
     // Print ALL named errors encountered so far
-    void printErrors(); 
+    void printErrors();
 
     // print known issues. return TRUE if there were any.
     UBool printKnownIssues();
-        
+
     virtual void usage( void ) ;
 
     /**
@@ -270,6 +253,30 @@ public:
      */
     static float random();
 
+
+    /**
+     *   Integer random numbers, similar to C++ std::minstd_rand, with the same algorithm
+     *   and constants.  Allow additional access to internal state, for use by monkey tests,
+     *   which need to recreate previous random sequences beginning near a failure point.
+     */
+    class icu_rand {
+      public:
+        icu_rand(uint32_t seed = 1);
+        ~icu_rand();
+        void seed(uint32_t seed);
+        uint32_t operator()();
+        /**
+          * Get a seed corresponding to the current state of the generator.
+          * Seeding any generator with this value will cause it to produce the
+          * same sequence as this one will from this point forward.
+          */
+        uint32_t getSeed();
+      private:
+        uint32_t fLast;
+    };
+
+
+
     enum { kMaxProps = 16 };
 
     virtual void setProperty(const char* propline);
@@ -292,6 +299,7 @@ protected:
                        UBool actual);
     UBool assertEquals(const char* message, int32_t expected, int32_t actual);
     UBool assertEquals(const char* message, int64_t expected, int64_t actual);
+    UBool assertEquals(const char* message, double expected, double actual);
 #if !UCONFIG_NO_FORMATTING
     UBool assertEquals(const char* message, const Formattable& expected,
                        const Formattable& actual, UBool possibleDataError=FALSE);
@@ -336,7 +344,7 @@ private:
     int32_t     dataErrorCount;
     IntlTest*   caller;
     char*       testPath;           // specifies subtests
-    
+
     char basePath[1024];
     char currName[1024]; // current test name