intl/icu/source/tools/ctestfw/unicode/testdata.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-2006, 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_TESTDATA
    12 #define U_TESTFW_TESTDATA
    14 #include "unicode/tstdtmod.h"
    15 #include "unicode/datamap.h"
    18  /** This is the class that abstracts one of the tests in a data file 
    19   *  It is usually instantiated using TestDataModule::CreateTestData method 
    20   *  This class provides two important methods: nextSettings and nextCase 
    21   *  Usually, one walks through all settings and executes all cases for 
    22   *  each setting. Each call to nextSettings resets the cases iterator.
    23   *  Individual test cases have to have the same number of fields as the
    24   *  number of entries in headers. Default headers can be specified in 
    25   *  the TestDataModule info section. The default headers will be overriden
    26   *  by per-test headers. 
    27   *  Example:                                             
    28   *  DataMap *settings = NULL;                            
    29   *  DataMap *cases = NULL;                               
    30   *  while(nextSettings(settings, status)) {              
    31   *    // set settings for the subtest                    
    32   *    while(nextCase(cases, status) {                    
    33   *      // process testcase                              
    34   *    }                                                  
    35   *   }                                                   
    36   */
    38 class T_CTEST_EXPORT_API TestData {
    39   const char* name;
    41 protected:
    42   DataMap *fInfo;
    43   DataMap *fCurrSettings;
    44   DataMap *fCurrCase;
    45   int32_t fSettingsSize;
    46   int32_t fCasesSize;
    47   int32_t fCurrentSettings;
    48   int32_t fCurrentCase;
    49   /** constructor - don't use */
    50   TestData(const char* name);
    52 public:
    53   virtual ~TestData();
    55   const char* getName() const;
    57   /** Get a pointer to an object owned DataMap that contains more information on this
    58    *  TestData object.
    59    *  Usual fields is "Description".                                   
    60    *  @param info pass in a const DataMap pointer. If no info, it will be set to NULL
    61    */
    62   virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0;
    64   /** Gets the next set of settings for the test. Resets the cases iterator. 
    65    *  DataMap is owned by the object and should not be deleted. 
    66    *  @param settings a DataMap pointer provided by the user. Will be NULL if 
    67    *                  no more settings are available.
    68    *  @param status for reporting unexpected errors.
    69    *  @return A boolean, TRUE if there are settings, FALSE if there is no more 
    70    *          settings. 
    71    */
    72   virtual UBool nextSettings(const DataMap *& settings, UErrorCode &status) = 0;
    74   /** Gets the next test case. 
    75    *  DataMap is owned by the object and should not be deleted. 
    76    *  @param data a DataMap pointer provided by the user. Will be NULL if 
    77    *                  no more cases are available.
    78    *  @param status for reporting unexpected errors.
    79    *  @return A boolean, TRUE if there are cases, FALSE if there is no more 
    80    *          cases. 
    81    */
    82   virtual UBool nextCase(const DataMap *& data, UErrorCode &status) = 0;
    83 };
    85 // implementation of TestData that uses resource bundles
    87 class T_CTEST_EXPORT_API RBTestData : public TestData {
    88   UResourceBundle *fData;
    89   UResourceBundle *fHeaders;
    90   UResourceBundle *fSettings;
    91   UResourceBundle *fCases;
    93 public:
    94   RBTestData(const char* name);
    95   RBTestData(UResourceBundle *data, UResourceBundle *headers, UErrorCode& status);
    96 private:
    97 //  RBTestData() {};
    98 //  RBTestData(const RBTestData& original) {};
    99   RBTestData& operator=(const RBTestData& /*original*/);
   101 public:
   102   virtual ~RBTestData();
   104   virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const;
   106   virtual UBool nextSettings(const DataMap *& settings, UErrorCode &status);
   107   virtual UBool nextCase(const DataMap *& nextCase, UErrorCode &status);
   108 };
   110 #endif

mercurial