home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / test / intltest / intltest.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  5.8 KB  |  156 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright Taligent, Inc.,  1997                                       *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1999     *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  10. *                                                                             *
  11. *******************************************************************************
  12. */
  13.  
  14. /*
  15.  * IntlTest in java is Copyright (c) 1997 Sun Microsystems, Inc. All
  16.  * Rights Reserved.  */
  17.  
  18. /**
  19.  * IntlTest is a base class for tests.  It is modelled according to,
  20.  * but not exactly similar to, JavaSoft's test class with the same
  21.  * name.  */
  22.  
  23. #ifndef _INTLTEST
  24. #define _INTLTEST
  25.  
  26. #include "utypes.h"
  27. #include "unistr.h"
  28. #include "coll.h"
  29. #include "sortkey.h"
  30. #include "fmtable.h" // liu
  31.  
  32. #include <iostream.h>
  33.  
  34. #define it_out (*IntlTest::gTest)
  35.  
  36. //-----------------------------------------------------------------------------
  37. //convenience classes to ease porting code that uses the Java
  38. //string-concatenation operator (moved from findword test by rtg)
  39. UnicodeString UCharToUnicodeString(UChar c);
  40. UnicodeString operator+(const UnicodeString& left, const UnicodeString& right);
  41. UnicodeString operator+(const UnicodeString& left, long num);
  42. UnicodeString operator+(const UnicodeString& left, unsigned long num);
  43. UnicodeString operator+(const UnicodeString& left, double num);
  44. UnicodeString operator+(const UnicodeString& left, char num); 
  45. UnicodeString operator+(const UnicodeString& left, short num);  
  46. UnicodeString operator+(const UnicodeString& left, int num);      
  47. UnicodeString operator+(const UnicodeString& left, unsigned char num);  
  48. UnicodeString operator+(const UnicodeString& left, unsigned short num);  
  49. UnicodeString operator+(const UnicodeString& left, unsigned int num);      
  50. UnicodeString operator+(const UnicodeString& left, float num);
  51. UnicodeString toString(const Formattable& f); // liu
  52. //-----------------------------------------------------------------------------
  53.  
  54. class IntlTest {
  55. public:
  56.  
  57.     IntlTest();
  58.  
  59.     virtual bool_t runTest( char* name = NULL, char* par = NULL ); // not to be overidden
  60.  
  61.     virtual bool_t setVerbose( bool_t verbose = TRUE );
  62.     virtual bool_t setNoErrMsg( bool_t no_err_msg = TRUE );
  63.     virtual bool_t setQuick( bool_t quick = TRUE );
  64.     virtual bool_t setLeaks( bool_t leaks = TRUE );
  65.  
  66.     virtual int32_t getErrors( void );
  67.  
  68.     virtual void setCaller( IntlTest* callingTest ); // for internal use only
  69.     virtual void setPath( char* path ); // for internal use only
  70.  
  71.     virtual void log( UnicodeString message );
  72.     
  73.     virtual void logln( UnicodeString message );
  74.  
  75.     virtual void logln( void );
  76.  
  77.     virtual void err(void);
  78.     
  79.     virtual void err( UnicodeString message );
  80.  
  81.     virtual void errln( UnicodeString message );
  82.     
  83.     virtual void usage( void ) ;
  84.  
  85.     ostream*    testout;
  86.  
  87. protected:
  88.     virtual void runIndexedTest( int32_t index, bool_t exec, char* &name, char* par = NULL ); // overide !
  89.  
  90.     virtual bool_t runTestLoop( char* testname, char* par );
  91.  
  92.     virtual int32_t IncErrorCount( void );
  93.  
  94.     virtual bool_t callTest( IntlTest& testToBeCalled, char* par );
  95.  
  96.  
  97.     bool_t      LL_linestart;
  98.     int32_t     LL_indentlevel;
  99.  
  100.     bool_t      verbose;
  101.     bool_t      no_err_msg;
  102.     bool_t      quick;
  103.     bool_t      leaks;
  104.     int32_t     errorCount;
  105.     IntlTest*   caller;
  106.     char*       path;           // specifies subtests
  107.  
  108.     virtual void LL_message( UnicodeString message, bool_t newline );
  109.  
  110.     // used for collation result reporting, defined here for convenience
  111.     virtual void reportCResult( UnicodeString &source, UnicodeString &target,
  112.                                 CollationKey &sourceKey, CollationKey &targetKey,
  113.                                 Collator::EComparisonResult compareResult,
  114.                                 Collator::EComparisonResult keyResult,
  115.                                 Collator::EComparisonResult expectedResult );
  116.  
  117.     static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target);
  118.     static UnicodeString &prettify(const CollationKey &source, UnicodeString &target);
  119.     static UnicodeString &appendHex(uint32_t number, int8_t digits, UnicodeString &target);
  120.     static UnicodeString &appendCompareResult(Collator::EComparisonResult result, UnicodeString &target);
  121.  
  122.     /* complete a relative path to a full pathname, and convert to platform-specific syntax. */
  123.     /* The character seperating directories for the relative path is '|'.                    */
  124.     static void pathnameInContext( char* fullname, int32_t maxsize, const char* relpath );
  125.     /*The function to set the Test Directory*/
  126.     static void setTestDirectory(const char* newDir);
  127.     /*The function to get the Test Directory*/
  128.     static const char* getTestDirectory(void);
  129.  
  130. public:
  131.     bool_t run_phase2( char* name, char* par ); // internally, supports reporting memory leaks
  132.  
  133. // static members
  134. public:
  135.     static IntlTest* gTest;
  136.  
  137. };
  138.  
  139.  
  140. void it_log( UnicodeString message );
  141. void it_logln( UnicodeString message );
  142. void it_logln( void );
  143. void it_err(void);
  144. void it_err( UnicodeString message );
  145. void it_errln( UnicodeString message );
  146.  
  147. IntlTest& operator<<(IntlTest& test, const UnicodeString& string);
  148. IntlTest& operator<<(IntlTest& test, const char* string);
  149. IntlTest& operator<<(IntlTest& test, const int32_t num);
  150.  
  151. IntlTest& endl( IntlTest& test );
  152. IntlTest& operator<<(IntlTest& test,  IntlTest& ( * _f)(IntlTest&));
  153.  
  154.  
  155. #endif // _INTLTEST
  156.