#include "normperf.h" UPerfFunction* NormalizerPerformanceTest::runIndexedTest(int32_t index, UBool exec,const char* &name, char* par) { switch (index) { TESTCASE(0,TestICU_NFC_NFD_Text); TESTCASE(1,TestICU_NFC_NFC_Text); TESTCASE(2,TestICU_NFC_Orig_Text); TESTCASE(3,TestICU_NFD_NFD_Text); TESTCASE(4,TestICU_NFD_NFC_Text); TESTCASE(5,TestICU_NFD_Orig_Text); TESTCASE(6,TestICU_FCD_NFD_Text); TESTCASE(7,TestICU_FCD_NFC_Text); TESTCASE(8,TestICU_FCD_Orig_Text); TESTCASE(9,TestWin_NFC_NFD_Text); TESTCASE(10,TestWin_NFC_NFC_Text); TESTCASE(11,TestWin_NFC_Orig_Text); TESTCASE(12,TestWin_NFD_NFD_Text); TESTCASE(13,TestWin_NFD_NFC_Text); TESTCASE(14,TestWin_NFD_Orig_Text); TESTCASE(15,TestQC_NFC_NFD_Text); TESTCASE(16,TestQC_NFC_NFC_Text); TESTCASE(17,TestQC_NFC_Orig_Text); TESTCASE(18,TestQC_NFD_NFD_Text); TESTCASE(19,TestQC_NFD_NFC_Text); TESTCASE(20,TestQC_NFD_Orig_Text); TESTCASE(21,TestQC_FCD_NFD_Text); TESTCASE(22,TestQC_FCD_NFC_Text); TESTCASE(23,TestQC_FCD_Orig_Text); TESTCASE(24,TestIsNormalized_NFC_NFD_Text); TESTCASE(25,TestIsNormalized_NFC_NFC_Text); TESTCASE(26,TestIsNormalized_NFC_Orig_Text); TESTCASE(27,TestIsNormalized_NFD_NFD_Text); TESTCASE(28,TestIsNormalized_NFD_NFC_Text); TESTCASE(29,TestIsNormalized_NFD_Orig_Text); TESTCASE(30,TestIsNormalized_FCD_NFD_Text); TESTCASE(31,TestIsNormalized_FCD_NFC_Text); TESTCASE(32,TestIsNormalized_FCD_Orig_Text); default: name = ""; return NULL; } return NULL; } void NormalizerPerformanceTest::normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode){ int32_t reqLen = 0; UErrorCode status = U_ZERO_ERROR; for(;;){ /* pure pre-flight */ reqLen=unorm_normalize(src,srcLen,mode,0,NULL,0,&status); if(status==U_BUFFER_OVERFLOW_ERROR){ status=U_ZERO_ERROR; dest->name = new UChar[reqLen+1]; reqLen= unorm_normalize(src,srcLen,mode,0,dest->name,reqLen+1,&status); dest->len=reqLen; break; }else if(U_FAILURE(status)){ printf("Could not normalize input. Error: %s", u_errorName(status)); } } } UChar* NormalizerPerformanceTest::normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode){ int32_t reqLen = 0; UErrorCode status = U_ZERO_ERROR; UChar* dest = NULL; for(;;){ /* pure pre-flight */ reqLen=unorm_normalize(src,srcLen,mode,0,NULL,0,&status); if(status==U_BUFFER_OVERFLOW_ERROR){ status=U_ZERO_ERROR; dest = new UChar[reqLen+1]; reqLen= unorm_normalize(src,srcLen,mode,0,dest,reqLen+1,&status); len=reqLen; break; }else if(U_FAILURE(status)){ printf("Could not normalize input. Error: %s", u_errorName(status)); } } return dest; } NormalizerPerformanceTest::NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status) : UPerfTest(argc,argv,status){ NFDBuffer = NULL; NFCBuffer = NULL; NFDBufferLen = 0; NFCBufferLen = 0; NFDFileLines = NULL; NFCFileLines = NULL; if(status== U_ILLEGAL_ARGUMENT_ERROR){ fprintf(stderr,gUsageString, "normperf"); return; } if(U_FAILURE(status)){ fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n", u_errorName(status)); return; } if(line_mode){ ULine* filelines = getLines(status); if(U_FAILURE(status)){ fprintf(stderr, "FAILED to read lines from file and create UPerfTest object. Error: %s\n", u_errorName(status)); return; } NFDFileLines = new ULine[numLines]; NFCFileLines = new ULine[numLines]; for(int32_t i=0;i