intl/icu/source/tools/ctestfw/unicode/tstdtmod.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /********************************************************************
     2  * COPYRIGHT: 
     3  * Copyright (c) 2002-2005, International Business Machines Corporation and
     4  * others. All Rights Reserved.
     5  ********************************************************************/
     7 /* Created by weiv 05/09/2002 */
     9 /* Base class for data driven tests */
    11 #ifndef U_TESTFW_TESTMODULE
    12 #define U_TESTFW_TESTMODULE
    14 #include "unicode/unistr.h"
    15 #include "unicode/ures.h"
    16 #include "unicode/testtype.h"
    17 #include "unicode/testdata.h"
    18 #include "unicode/datamap.h"
    19 #include "unicode/testlog.h"
    22 /* This class abstracts the actual organization of the  
    23  * data for data driven tests                           
    24  */
    27 class DataMap;
    28 class TestData;
    31 /** Main data driven test class. Corresponds to one named data 
    32  *  unit (such as a resource bundle. It is instantiated using  
    33  *  a factory method getTestDataModule 
    34  */
    35 class T_CTEST_EXPORT_API TestDataModule {
    36   const char* testName;
    38 protected:
    39   DataMap *fInfo;
    40   TestLog& fLog;
    42 public:
    43   /** Factory method. 
    44    *  @param name name of the test module. Usually name of a resource bundle or a XML file 
    45    *  @param log a logging class, used for internal error reporting.                       
    46    *  @param status if something goes wrong, status will be set                            
    47    *  @return a TestDataModule object. Use it to get test data from it                     
    48    */
    49   static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status);
    50   virtual ~TestDataModule();
    52 protected:
    53   TestDataModule(const char* name, TestLog& log, UErrorCode& status);
    55 public:
    56   /** Name of this TestData module. 
    57    *  @return a name 
    58    */
    59   const char * getName() const;
    61   /** Get a pointer to an object owned DataMap that contains more information on this module 
    62    *  Usual fields are "Description", "LongDescription", "Settings". Also, if containing a   
    63    *  field "Headers" these will be used as the default headers, so that you don't have to   
    64    *  to specify per test headers.                                                           
    65    *  @param info pass in a const DataMap pointer. If no info, it will be set to NULL
    66    */
    67   virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0;
    69   /** Create a test data object from an index. Helpful for integrating tests with current 
    70    *  intltest framework which addresses the tests by index.                              
    71    *  @param index index of the test to be instantiated                                   
    72    *  @return an instantiated TestData object, ready to provide settings and cases for    
    73    *          the tests.                                                                  
    74    */
    75   virtual TestData* createTestData(int32_t index, UErrorCode &status) const = 0;
    77   /** Create a test data object from a name.                              
    78    *  @param name name of the test to be instantiated                                     
    79    *  @return an instantiated TestData object, ready to provide settings and cases for    
    80    *          the tests.                                                                  
    81    */
    82   virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0;
    83 };
    85 class T_CTEST_EXPORT_API RBTestDataModule : public TestDataModule {
    86 public:
    87   virtual ~RBTestDataModule();
    89 public:
    90   RBTestDataModule(const char* name, TestLog& log, UErrorCode& status);
    92 public:
    93   virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const;
    95   virtual TestData* createTestData(int32_t index, UErrorCode &status) const;
    96   virtual TestData* createTestData(const char* name, UErrorCode &status) const;
    98 private:
    99   UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status);
   101 private:
   102   UResourceBundle *fModuleBundle;
   103   UResourceBundle *fTestData;
   104   UResourceBundle *fInfoRB;
   105   UBool fDataTestValid;
   106   char *tdpath;
   108 /* const char* fTestName;*/ /* See name */
   109   int32_t fNumberOfTests;
   111 };
   114 #endif

mercurial