ICU-6845 Improve the code coverage in ICU4C.
X-SVN-Rev: 28790
This commit is contained in:
parent
801abaa192
commit
2333b126c1
@ -22,6 +22,7 @@
|
||||
#include "unicode/ustring.h"
|
||||
#include "cmemory.h"
|
||||
#include "cstring.h"
|
||||
#include "propsvec.h"
|
||||
|
||||
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
|
||||
|
||||
@ -30,11 +31,13 @@
|
||||
#define TDSRCPATH ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING
|
||||
|
||||
static void TestSelector(void);
|
||||
static void TestUPropsVector(void);
|
||||
void addCnvSelTest(TestNode** root); /* Declaration required to suppress compiler warnings. */
|
||||
|
||||
void addCnvSelTest(TestNode** root)
|
||||
{
|
||||
addTest(root, &TestSelector, "tsconv/ucnvseltst/TestSelector");
|
||||
addTest(root, &TestUPropsVector, "tsconv/ucnvseltst/TestUPropsVector");
|
||||
}
|
||||
|
||||
static const char **gAvailableNames = NULL;
|
||||
@ -500,3 +503,38 @@ static void TestSelector()
|
||||
uset_close(excluded_sets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Improve code coverage of UPropsVectors */
|
||||
static void TestUPropsVector() {
|
||||
uint32_t value;
|
||||
UErrorCode errorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
UPropsVectors *pv = upvec_open(100, &errorCode);
|
||||
if (pv != NULL) {
|
||||
log_err("Should have returned NULL if UErrorCode is an error.");
|
||||
return;
|
||||
}
|
||||
errorCode = U_ZERO_ERROR;
|
||||
pv = upvec_open(-1, &errorCode);
|
||||
if (pv != NULL || U_SUCCESS(errorCode)) {
|
||||
log_err("Should have returned NULL if column is less than 0.\n");
|
||||
return;
|
||||
}
|
||||
errorCode = U_ZERO_ERROR;
|
||||
pv = upvec_open(100, &errorCode);
|
||||
if (pv == NULL || U_FAILURE(errorCode)) {
|
||||
log_err("Unable to open UPropsVectors.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (upvec_getValue(pv, 0, 1) != 0) {
|
||||
log_err("upvec_getValue should return 0.\n");
|
||||
}
|
||||
if (upvec_getRow(pv, 0, NULL, NULL) == NULL) {
|
||||
log_err("upvec_getRow should not return NULL.\n");
|
||||
}
|
||||
if (upvec_getArray(pv, NULL, NULL) != NULL) {
|
||||
log_err("upvec_getArray should return NULL.\n");
|
||||
}
|
||||
|
||||
upvec_close(pv);
|
||||
}
|
||||
|
@ -545,6 +545,12 @@ StringTest::TestCharString() {
|
||||
if (0 != strcmp(longStr, chStr.data()) || (int32_t)strlen(longStr) != chStr.length()) {
|
||||
errln("CharString(longStr) failed.");
|
||||
}
|
||||
CharString test("Test", errorCode);
|
||||
CharString copy(test,errorCode);
|
||||
copy.copyFrom(chStr, errorCode);
|
||||
if (0 != strcmp(longStr, copy.data()) || (int32_t)strlen(longStr) != copy.length()) {
|
||||
errln("CharString.copyFrom() failed.");
|
||||
}
|
||||
StringPiece sp(chStr.toStringPiece());
|
||||
sp.remove_prefix(4);
|
||||
chStr.append(sp, errorCode).append(chStr, errorCode);
|
||||
|
@ -56,6 +56,7 @@ void BasicNormalizerTest::runIndexedTest(int32_t index, UBool exec,
|
||||
CASE(17,TestCustomComp);
|
||||
CASE(18,TestCustomFCC);
|
||||
#endif
|
||||
CASE(19,TestFilteredNormalizer2Coverage);
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
@ -1448,4 +1449,30 @@ BasicNormalizerTest::TestCustomFCC() {
|
||||
}
|
||||
}
|
||||
|
||||
/* Improve code coverage of Normalizer2 */
|
||||
void
|
||||
BasicNormalizerTest::TestFilteredNormalizer2Coverage() {
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
const Normalizer2 *nfcNorm2=Normalizer2Factory::getNFCInstance(errorCode);
|
||||
UnicodeSet filter(UNICODE_STRING_SIMPLE("[^\\u00a0-\\u00ff]"), errorCode);
|
||||
UnicodeString newString1 = UNICODE_STRING_SIMPLE("[^\\u0100-\\u01ff]");
|
||||
UnicodeString newString2 = UNICODE_STRING_SIMPLE("[^\\u0200-\\u02ff]");
|
||||
FilteredNormalizer2 fn2(*nfcNorm2, filter);
|
||||
|
||||
UChar32 char32 = 0x0054;
|
||||
|
||||
if (fn2.isInert(char32)) {
|
||||
errln("FilteredNormalizer2.isInert() failed.");
|
||||
}
|
||||
|
||||
if (fn2.hasBoundaryAfter(char32)) {
|
||||
errln("FilteredNormalizer2.hasBoundaryAfter() failed.");
|
||||
}
|
||||
|
||||
fn2.append(newString1, newString2, errorCode);
|
||||
if (U_FAILURE(errorCode)) {
|
||||
errln("FilteredNormalizer2.append() failed.");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_NORMALIZATION */
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
void TestSkippable();
|
||||
void TestCustomComp();
|
||||
void TestCustomFCC();
|
||||
void TestFilteredNormalizer2Coverage();
|
||||
|
||||
private:
|
||||
UnicodeString canonTests[24][3];
|
||||
|
Loading…
Reference in New Issue
Block a user