X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..2be6500137966bba13903b24204a44804f9e133a:/icuSources/test/intltest/intltest.h diff --git a/icuSources/test/intltest/intltest.h b/icuSources/test/intltest/intltest.h index 531c883a..e71576d2 100644 --- a/icuSources/test/intltest/intltest.h +++ b/icuSources/test/intltest/intltest.h @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2010, International Business Machines Corporation and + * Copyright (c) 1997-2013, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -15,11 +15,34 @@ #include "unicode/fmtable.h" #include "unicode/testlog.h" + +#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 +#endif + U_NAMESPACE_USE -#ifdef OS390 +#if U_PLATFORM == U_PF_OS390 // avoid collision with math.h/log() -// this must be after including utypes.h so that OS390 is actually defined +// this must be after including utypes.h so that U_PLATFORM is actually defined #pragma map(IntlTest::log( const UnicodeString &message ),"logos390") #endif @@ -97,6 +120,9 @@ UnicodeString toString(int32_t n); break; \ } +#define TEST_ASSERT_TRUE(x) \ + assertTrue(#x, (x), FALSE, FALSE, __FILE__, __LINE__) + class IntlTest : public TestLog { public: @@ -109,6 +135,7 @@ public: virtual UBool setNoErrMsg( UBool no_err_msg = TRUE ); virtual UBool setQuick( UBool quick = TRUE ); virtual UBool setLeaks( UBool leaks = TRUE ); + virtual UBool setNotime( UBool no_time = TRUE ); virtual UBool setWarnOnMissingData( UBool warn_on_missing_data = TRUE ); virtual int32_t setThreadCount( int32_t count = 1); @@ -175,10 +202,30 @@ public: static float random(); /** - * Ascertain the version of ICU. Useful for - * time bomb testing + * Returns true if u_getVersion() < major.minor. */ - UBool isICUVersionAtLeast(const UVersionInfo x); + static UBool isICUVersionBefore(int major, int minor) { + return isICUVersionBefore(major, minor, 0); + } + + /** + * Returns true if u_getVersion() < major.minor.milli. + */ + static UBool isICUVersionBefore(int major, int minor, int milli); + + /** + * Returns true if u_getVersion() >= major.minor. + */ + static UBool isICUVersionAtLeast(int major, int minor) { + return isICUVersionAtLeast(major, minor, 0); + } + + /** + * Returns true if u_getVersion() >= major.minor.milli. + */ + static UBool isICUVersionAtLeast(int major, int minor, int milli) { + return !isICUVersionBefore(major, minor, milli); + } enum { kMaxProps = 16 }; @@ -187,13 +234,14 @@ public: protected: /* JUnit-like assertions. Each returns TRUE if it succeeds. */ - UBool assertTrue(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE); + UBool assertTrue(const char* message, UBool condition, UBool quiet=FALSE, UBool possibleDataError=FALSE, const char *file=NULL, int line=0); UBool assertFalse(const char* message, UBool condition, UBool quiet=FALSE); UBool assertSuccess(const char* message, UErrorCode ec, UBool possibleDataError=FALSE); UBool assertEquals(const char* message, const UnicodeString& expected, const UnicodeString& actual, UBool possibleDataError=FALSE); UBool assertEquals(const char* message, const char* expected, const char* actual); + UBool assertEquals(const char* message, int32_t expected, int32_t actual); #if !UCONFIG_NO_FORMATTING UBool assertEquals(const char* message, const Formattable& expected, const Formattable& actual); @@ -224,6 +272,7 @@ protected: UBool quick; UBool leaks; UBool warn_on_missing_data; + UBool no_time; int32_t threadCount; private: @@ -251,7 +300,12 @@ protected: static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target); static UnicodeString prettify(const UnicodeString &source, UBool parseBackslash=FALSE); + // digits=-1 determines the number of digits automatically static UnicodeString &appendHex(uint32_t number, int32_t digits, UnicodeString &target); + static UnicodeString toHex(uint32_t number, int32_t digits=-1); + static inline UnicodeString toHex(int32_t number, int32_t digits=-1) { + return toHex((uint32_t)number, digits); + } public: static void setICU_DATA(); // Set up ICU_DATA if necessary.