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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/tools/ctestfw/unicode/tstdtmod.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,115 @@
     1.4 +/********************************************************************
     1.5 + * COPYRIGHT: 
     1.6 + * Copyright (c) 2002-2005, International Business Machines Corporation and
     1.7 + * others. All Rights Reserved.
     1.8 + ********************************************************************/
     1.9 +
    1.10 +/* Created by weiv 05/09/2002 */
    1.11 +
    1.12 +/* Base class for data driven tests */
    1.13 +
    1.14 +#ifndef U_TESTFW_TESTMODULE
    1.15 +#define U_TESTFW_TESTMODULE
    1.16 +
    1.17 +#include "unicode/unistr.h"
    1.18 +#include "unicode/ures.h"
    1.19 +#include "unicode/testtype.h"
    1.20 +#include "unicode/testdata.h"
    1.21 +#include "unicode/datamap.h"
    1.22 +#include "unicode/testlog.h"
    1.23 +
    1.24 +
    1.25 +/* This class abstracts the actual organization of the  
    1.26 + * data for data driven tests                           
    1.27 + */
    1.28 +
    1.29 +
    1.30 +class DataMap;
    1.31 +class TestData;
    1.32 +
    1.33 +
    1.34 +/** Main data driven test class. Corresponds to one named data 
    1.35 + *  unit (such as a resource bundle. It is instantiated using  
    1.36 + *  a factory method getTestDataModule 
    1.37 + */
    1.38 +class T_CTEST_EXPORT_API TestDataModule {
    1.39 +  const char* testName;
    1.40 +
    1.41 +protected:
    1.42 +  DataMap *fInfo;
    1.43 +  TestLog& fLog;
    1.44 +
    1.45 +public:
    1.46 +  /** Factory method. 
    1.47 +   *  @param name name of the test module. Usually name of a resource bundle or a XML file 
    1.48 +   *  @param log a logging class, used for internal error reporting.                       
    1.49 +   *  @param status if something goes wrong, status will be set                            
    1.50 +   *  @return a TestDataModule object. Use it to get test data from it                     
    1.51 +   */
    1.52 +  static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status);
    1.53 +  virtual ~TestDataModule();
    1.54 +
    1.55 +protected:
    1.56 +  TestDataModule(const char* name, TestLog& log, UErrorCode& status);
    1.57 +
    1.58 +public:
    1.59 +  /** Name of this TestData module. 
    1.60 +   *  @return a name 
    1.61 +   */
    1.62 +  const char * getName() const;
    1.63 +
    1.64 +  /** Get a pointer to an object owned DataMap that contains more information on this module 
    1.65 +   *  Usual fields are "Description", "LongDescription", "Settings". Also, if containing a   
    1.66 +   *  field "Headers" these will be used as the default headers, so that you don't have to   
    1.67 +   *  to specify per test headers.                                                           
    1.68 +   *  @param info pass in a const DataMap pointer. If no info, it will be set to NULL
    1.69 +   */
    1.70 +  virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0;
    1.71 +
    1.72 +  /** Create a test data object from an index. Helpful for integrating tests with current 
    1.73 +   *  intltest framework which addresses the tests by index.                              
    1.74 +   *  @param index index of the test to be instantiated                                   
    1.75 +   *  @return an instantiated TestData object, ready to provide settings and cases for    
    1.76 +   *          the tests.                                                                  
    1.77 +   */
    1.78 +  virtual TestData* createTestData(int32_t index, UErrorCode &status) const = 0;
    1.79 +
    1.80 +  /** Create a test data object from a name.                              
    1.81 +   *  @param name name of the test to be instantiated                                     
    1.82 +   *  @return an instantiated TestData object, ready to provide settings and cases for    
    1.83 +   *          the tests.                                                                  
    1.84 +   */
    1.85 +  virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0;
    1.86 +};
    1.87 +
    1.88 +class T_CTEST_EXPORT_API RBTestDataModule : public TestDataModule {
    1.89 +public:
    1.90 +  virtual ~RBTestDataModule();
    1.91 +
    1.92 +public:
    1.93 +  RBTestDataModule(const char* name, TestLog& log, UErrorCode& status);
    1.94 +
    1.95 +public:
    1.96 +  virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const;
    1.97 +
    1.98 +  virtual TestData* createTestData(int32_t index, UErrorCode &status) const;
    1.99 +  virtual TestData* createTestData(const char* name, UErrorCode &status) const;
   1.100 +
   1.101 +private:
   1.102 +  UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status);
   1.103 +
   1.104 +private:
   1.105 +  UResourceBundle *fModuleBundle;
   1.106 +  UResourceBundle *fTestData;
   1.107 +  UResourceBundle *fInfoRB;
   1.108 +  UBool fDataTestValid;
   1.109 +  char *tdpath;
   1.110 +
   1.111 +/* const char* fTestName;*/ /* See name */
   1.112 +  int32_t fNumberOfTests;
   1.113 +
   1.114 +};
   1.115 +
   1.116 +
   1.117 +#endif
   1.118 +

mercurial