| OLD | NEW | 
|    1 /* |    1 /* | 
|    2 ********************************************************************** |    2 ********************************************************************** | 
|    3 * Copyright (c) 2002-2011, International Business Machines |    3 * Copyright (c) 2002-2014, International Business Machines | 
|    4 * Corporation and others.  All Rights Reserved. |    4 * Corporation and others.  All Rights Reserved. | 
|    5 ********************************************************************** |    5 ********************************************************************** | 
|    6 */ |    6 */ | 
|    7 #ifndef _UPERF_H |    7 #ifndef _UPERF_H | 
|    8 #define _UPERF_H |    8 #define _UPERF_H | 
|    9  |    9  | 
|   10 #include "unicode/utypes.h" |   10 #include "unicode/utypes.h" | 
|   11 #include "unicode/unistr.h" |   11 #include "unicode/unistr.h" | 
|   12 #include "unicode/ustring.h" |   12 #include "unicode/ustring.h" | 
|   13  |   13  | 
|   14 #include "unicode/testtype.h" |   14 #include "unicode/testtype.h" | 
|   15 #include "unicode/utimer.h" |   15 #include "unicode/utimer.h" | 
|   16 #include "ucbuf.h" |   16 #include "ucbuf.h" | 
|   17  |   17  | 
|   18 // Forward declarations from uoptions.h. |   18 // Forward declarations from uoptions.h. | 
|   19 struct UOption; |   19 struct UOption; | 
|   20 typedef struct UOption UOption; |   20 typedef struct UOption UOption; | 
|   21  |   21  | 
|   22 #if !UCONFIG_NO_CONVERSION |   22 #if !UCONFIG_NO_CONVERSION | 
|   23  |   23  | 
|   24 U_NAMESPACE_USE |   24 U_NAMESPACE_USE | 
|   25 // Use the TESTCASE macro in subclasses of IntlTest.  Define the |   25 // Use the TESTCASE macro in subclasses of UPerfTest. Define the | 
|   26 // runIndexedTest method in this fashion: |   26 // runIndexedTest method in this fashion: | 
|   27 // |   27 // | 
|   28 //| void MyTest::runIndexedTest(int32_t index, UBool exec, |   28 //| void MyTest::runIndexedTest(int32_t index, UBool exec, | 
|   29 //|                             const char* &name, char* /*par*/) { |   29 //|                             const char* &name, char* /*par*/) { | 
|   30 //|     switch (index) { |   30 //|     switch (index) { | 
|   31 //|         TESTCASE(0,TestSomething); |   31 //|         TESTCASE(0,TestSomething); | 
|   32 //|         TESTCASE(1,TestSomethingElse); |   32 //|         TESTCASE(1,TestSomethingElse); | 
|   33 //|         TESTCASE(2,TestAnotherThing); |   33 //|         TESTCASE(2,TestAnotherThing); | 
|   34 //|         default:  |   34 //|         default:  | 
|   35 //|             name = "";  |   35 //|             name = ""; | 
|   36 //|             return NULL; |   36 //|             break; | 
|   37 //|     } |   37 //|     } | 
 |   38 //|     return NULL; | 
|   38 //| } |   39 //| } | 
|   39 #if 0 |  | 
|   40 #define TESTCASE(id,test)                       \ |  | 
|   41     case id:                                    \ |  | 
|   42         name = #test;                           \ |  | 
|   43         if (exec) {                             \ |  | 
|   44             fprintf(stdout,#test "---");        \ |  | 
|   45             fprintf(stdout,"\n");               \ |  | 
|   46             return test();                      \ |  | 
|   47         }                                       \ |  | 
|   48         break |  | 
|   49  |  | 
|   50 #endif |  | 
|   51 #define TESTCASE(id,test)                       \ |   40 #define TESTCASE(id,test)                       \ | 
|   52     case id:                                    \ |   41     case id:                                    \ | 
|   53         name = #test;                           \ |   42         name = #test;                           \ | 
|   54         if (exec) {                             \ |   43         if (exec) {                             \ | 
|   55             return test();                      \ |   44             return test();                      \ | 
|   56         }                                       \ |   45         }                                       \ | 
|   57         break |   46         break | 
|   58  |   47  | 
 |   48 // More convenient macros. These allow easy reordering of the test cases. | 
 |   49 // Copied from intltest.h, and adjusted to not logln() but return a UPerfFunctio
     n. | 
 |   50 // | 
 |   51 //| void MyTest::runIndexedTest(int32_t index, UBool exec, | 
 |   52 //|                             const char* &name, char* /*par*/) { | 
 |   53 //|     TESTCASE_AUTO_BEGIN; | 
 |   54 //|     TESTCASE_AUTO(TestSomething); | 
 |   55 //|     TESTCASE_AUTO(TestSomethingElse); | 
 |   56 //|     TESTCASE_AUTO(TestAnotherThing); | 
 |   57 //|     TESTCASE_AUTO_END; | 
 |   58 //|     return NULL; | 
 |   59 //| } | 
 |   60 #define TESTCASE_AUTO_BEGIN \ | 
 |   61     for(;;) { \ | 
 |   62         int32_t testCaseAutoNumber = 0 | 
 |   63  | 
 |   64 #define TESTCASE_AUTO(test) \ | 
 |   65         if (index == testCaseAutoNumber++) { \ | 
 |   66             name = #test; \ | 
 |   67             if (exec) { \ | 
 |   68                 return test(); \ | 
 |   69             } \ | 
 |   70             break; \ | 
 |   71         } | 
 |   72  | 
 |   73 #define TESTCASE_AUTO_END \ | 
 |   74         name = ""; \ | 
 |   75         break; \ | 
 |   76     } | 
 |   77  | 
|   59 /** |   78 /** | 
|   60  * Subclasses of PerfTest will need to create subclasses of |   79  * Subclasses of PerfTest will need to create subclasses of | 
|   61  * Function that define a call() method which contains the code to |   80  * Function that define a call() method which contains the code to | 
|   62  * be timed.  They then call setTestFunction() in their "Test..." |   81  * be timed.  They then call setTestFunction() in their "Test..." | 
|   63  * method to establish this as the current test functor. |   82  * method to establish this as the current test functor. | 
|   64  */ |   83  */ | 
|   65 class T_CTEST_EXPORT_API UPerfFunction { |   84 class T_CTEST_EXPORT_API UPerfFunction { | 
|   66 public: |   85 public: | 
|   67     /** |   86     /** | 
|   68      * destructor |   87      * destructor | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  170  |  189  | 
|  171 // static members |  190 // static members | 
|  172 public: |  191 public: | 
|  173     static UPerfTest* gTest; |  192     static UPerfTest* gTest; | 
|  174     static const char gUsageString[]; |  193     static const char gUsageString[]; | 
|  175 }; |  194 }; | 
|  176  |  195  | 
|  177 #endif |  196 #endif | 
|  178 #endif |  197 #endif | 
|  179  |  198  | 
| OLD | NEW |