ICU-5032 Refactor code while increasing code coverage.
X-SVN-Rev: 19380
This commit is contained in:
parent
b492fe71a3
commit
efedac815e
@ -480,9 +480,6 @@
|
||||
<File
|
||||
RelativePath=".\cucdtst.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cucdtst.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\usettest.c">
|
||||
</File>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2005, International Business Machines
|
||||
* Copyright (C) 2002-2006, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
/* test string case mapping functions --------------------------------------- */
|
||||
|
||||
U_CFUNC void
|
||||
TestCaseLower() {
|
||||
static void
|
||||
TestCaseLower(void) {
|
||||
static const UChar
|
||||
|
||||
beforeLower[]= { 0x61, 0x42, 0x49, 0x3a3, 0xdf, 0x3a3, 0x2f, 0xd93f, 0xdfff },
|
||||
@ -127,8 +127,8 @@ buffer[length]==0 ? "yes" : "no",
|
||||
}
|
||||
}
|
||||
|
||||
U_CFUNC void
|
||||
TestCaseUpper() {
|
||||
static void
|
||||
TestCaseUpper(void) {
|
||||
static const UChar
|
||||
|
||||
beforeUpper[]= { 0x61, 0x42, 0x69, 0x3c2, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
|
||||
@ -223,8 +223,8 @@ TestCaseUpper() {
|
||||
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
|
||||
U_CFUNC void
|
||||
TestCaseTitle() {
|
||||
static void
|
||||
TestCaseTitle(void) {
|
||||
static const UChar
|
||||
|
||||
beforeTitle[]= { 0x61, 0x42, 0x20, 0x69, 0x3c2, 0x20, 0xdf, 0x3c3, 0x2f, 0xfb03, 0xd93f, 0xdfff },
|
||||
@ -331,8 +331,8 @@ TestCaseTitle() {
|
||||
|
||||
/* test case folding and case-insensitive string compare -------------------- */
|
||||
|
||||
U_CFUNC void
|
||||
TestCaseFolding() {
|
||||
static void
|
||||
TestCaseFolding(void) {
|
||||
/*
|
||||
* CaseFolding.txt says about i and its cousins:
|
||||
* 0049; C; 0069; # LATIN CAPITAL LETTER I
|
||||
@ -557,8 +557,8 @@ TestCaseFolding() {
|
||||
}
|
||||
}
|
||||
|
||||
U_CFUNC void
|
||||
TestCaseCompare() {
|
||||
static void
|
||||
TestCaseCompare(void) {
|
||||
static const UChar
|
||||
|
||||
mixed[]= { 0x61, 0x42, 0x131, 0x3a3, 0xdf, 0xfb03, 0xd93f, 0xdfff, 0 },
|
||||
@ -653,8 +653,8 @@ TestCaseCompare() {
|
||||
* test cases for actual case mappings using UCaseMap see
|
||||
* intltest utility/UnicodeStringTest/StringCaseTest/TestCasing
|
||||
*/
|
||||
U_CFUNC void
|
||||
TestUCaseMap() {
|
||||
static void
|
||||
TestUCaseMap(void) {
|
||||
static const char
|
||||
aBc[] ={ 0x61, 0x42, 0x63, 0 },
|
||||
abc[] ={ 0x61, 0x62, 0x63, 0 },
|
||||
@ -779,3 +779,17 @@ TestUCaseMap() {
|
||||
|
||||
ucasemap_close(csm);
|
||||
}
|
||||
|
||||
void addCaseTest(TestNode** root);
|
||||
|
||||
void addCaseTest(TestNode** root) {
|
||||
/* cstrcase.c functions, declared in cucdtst.h */
|
||||
addTest(root, &TestCaseLower, "tsutil/cstrcase/TestCaseLower");
|
||||
addTest(root, &TestCaseUpper, "tsutil/cstrcase/TestCaseUpper");
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
addTest(root, &TestCaseTitle, "tsutil/cstrcase/TestCaseTitle");
|
||||
#endif
|
||||
addTest(root, &TestCaseFolding, "tsutil/cstrcase/TestCaseFolding");
|
||||
addTest(root, &TestCaseCompare, "tsutil/cstrcase/TestCaseCompare");
|
||||
addTest(root, &TestUCaseMap, "tsutil/cstrcase/TestUCaseMap");
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
*
|
||||
* File CUCDTST.H
|
||||
*
|
||||
* Modification History:
|
||||
* Name Description
|
||||
* Madhu Katragadda Converted to C, added tests for string functions
|
||||
*********************************************************************************
|
||||
*/
|
||||
/* C API TEST For Unicode */
|
||||
|
||||
#ifndef _CUCDTST
|
||||
#define _CUCDTST
|
||||
|
||||
/* cstrcase.c */
|
||||
U_CFUNC void TestCaseLower(void);
|
||||
U_CFUNC void TestCaseUpper(void);
|
||||
U_CFUNC void TestCaseTitle(void);
|
||||
U_CFUNC void TestCaseFolding(void);
|
||||
U_CFUNC void TestCaseCompare(void);
|
||||
U_CFUNC void TestUCaseMap(void);
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2005, International Business Machines
|
||||
* Copyright (C) 2002-2006, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
@ -16,15 +16,12 @@
|
||||
* Tests of ustring.h Unicode string API functions.
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/uloc.h"
|
||||
#include "unicode/ucnv.h"
|
||||
#include "unicode/uiter.h"
|
||||
#include "cintltst.h"
|
||||
#include "cucdtst.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
|
||||
|
||||
@ -42,6 +39,7 @@ static void TestUnescape(void);
|
||||
static void TestCountChar32(void);
|
||||
static void TestUCharIterator(void);
|
||||
static void TestUNormIterator(void);
|
||||
static void TestBadUNormIterator(void);
|
||||
|
||||
void addUStringTest(TestNode** root);
|
||||
|
||||
@ -55,16 +53,7 @@ void addUStringTest(TestNode** root)
|
||||
addTest(root, &TestCountChar32, "tsutil/custrtst/TestCountChar32");
|
||||
addTest(root, &TestUCharIterator, "tsutil/custrtst/TestUCharIterator");
|
||||
addTest(root, &TestUNormIterator, "tsutil/custrtst/TestUNormIterator");
|
||||
|
||||
/* cstrcase.c functions, declared in cucdtst.h */
|
||||
addTest(root, &TestCaseLower, "tsutil/custrtst/TestCaseLower");
|
||||
addTest(root, &TestCaseUpper, "tsutil/custrtst/TestCaseUpper");
|
||||
#if !UCONFIG_NO_BREAK_ITERATION
|
||||
addTest(root, &TestCaseTitle, "tsutil/custrtst/TestCaseTitle");
|
||||
#endif
|
||||
addTest(root, &TestCaseFolding, "tsutil/custrtst/TestCaseFolding");
|
||||
addTest(root, &TestCaseCompare, "tsutil/custrtst/TestCaseCompare");
|
||||
addTest(root, &TestUCaseMap, "tsutil/custrtst/TestUCaseMap");
|
||||
addTest(root, &TestBadUNormIterator, "tsutil/custrtst/TestBadUNormIterator");
|
||||
}
|
||||
|
||||
/* test data for TestStringFunctions ---------------------------------------- */
|
||||
@ -1795,4 +1784,30 @@ TestUNormIterator() {
|
||||
testUNormIteratorWithText(surrogateText, length, length, "UCharIterSurrEnd", "UNormIterSurrEnd1");
|
||||
}
|
||||
|
||||
static void
|
||||
TestBadUNormIterator(void) {
|
||||
#if !UCONFIG_NO_NORMALIZATION
|
||||
UErrorCode status = U_ILLEGAL_ESCAPE_SEQUENCE;
|
||||
UNormIterator *uni;
|
||||
|
||||
unorm_setIter(NULL, NULL, UNORM_NONE, &status);
|
||||
if (status != U_ILLEGAL_ESCAPE_SEQUENCE) {
|
||||
log_err("unorm_setIter changed the error code to: %s\n", u_errorName(status));
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
unorm_setIter(NULL, NULL, UNORM_NONE, &status);
|
||||
if (status != U_ILLEGAL_ARGUMENT_ERROR) {
|
||||
log_err("unorm_setIter didn't react correctly to bad arguments: %s\n", u_errorName(status));
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
uni=unorm_openIter(NULL, 0, &status);
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("unorm_openIter() fails: %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
unorm_setIter(uni, NULL, UNORM_NONE, &status);
|
||||
unorm_closeIter(uni);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2006, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
@ -18,6 +18,7 @@ void addLocaleTest(TestNode**);
|
||||
void addCLDRTest(TestNode**);
|
||||
void addUnicodeTest(TestNode**);
|
||||
void addUStringTest(TestNode**);
|
||||
void addCaseTest(TestNode**);
|
||||
void addResourceBundleTest(TestNode**);
|
||||
void addNEWResourceBundleTest(TestNode**);
|
||||
void addHashtableTest(TestNode** root);
|
||||
@ -37,6 +38,7 @@ void addUtility(TestNode** root)
|
||||
addCLDRTest(root);
|
||||
addUnicodeTest(root);
|
||||
addUStringTest(root);
|
||||
addCaseTest(root);
|
||||
addResourceBundleTest(root);
|
||||
addNEWResourceBundleTest(root);
|
||||
addHashtableTest(root);
|
||||
|
Loading…
Reference in New Issue
Block a user