+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2002-2006, International Business Machines Corporation and
+ * Copyright (c) 2002-2016, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************
*
#if !UCONFIG_NO_NORMALIZATION
#include "intltest.h"
+#include "cmemory.h"
#include "cstring.h"
#include "canittst.h"
#include "unicode/caniter.h"
#include "unicode/uchar.h"
#include "hash.h"
-#define ARRAY_LENGTH(array) ((int32_t)(sizeof (array) / sizeof (*array)))
-
#define CASE(id,test) case id: \
name = #test; \
if (exec) { \
void CanonicalIteratorTest::TestExhaustive() {
UErrorCode status = U_ZERO_ERROR;
CanonicalIterator it("", status);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating CanonicalIterator: %s", u_errorName(status));
+ return;
+ }
UChar32 i = 0;
UnicodeString s;
// Test static and dynamic class IDs
// NOTE: we use a TreeSet below to sort the output, which is not guaranteed to be sorted!
Hashtable *permutations = new Hashtable(FALSE, status);
- permutations->setValueDeleter(uhash_deleteUnicodeString);
+ permutations->setValueDeleter(uprv_deleteUObject);
UnicodeString toPermute("ABC");
CanonicalIterator::permute(toPermute, FALSE, permutations, status);
// try samples
logln("testing samples");
Hashtable *set = new Hashtable(FALSE, status);
- set->setValueDeleter(uhash_deleteUnicodeString);
+ set->setValueDeleter(uprv_deleteUObject);
int32_t i = 0;
CanonicalIterator it("", status);
if(U_SUCCESS(status)) {
- for (i = 0; i < ARRAY_LENGTH(testArray); ++i) {
+ for (i = 0; i < UPRV_LENGTHOF(testArray); ++i) {
//logln("Results for: " + name.transliterate(testArray[i]));
UnicodeString testStr = CharsToUnicodeString(testArray[i][0]);
it.setSource(testStr, status);
set->removeAll();
- while (TRUE) {
+ for (;;) {
//UnicodeString *result = new UnicodeString(it.next());
UnicodeString result(it.next());
if (result.isBogus()) {
//logln(++counter + ": " + hex.transliterate(result));
//logln(" = " + name.transliterate(result));
}
- expectEqual(i + ": ", testStr, collectionToString(set), CharsToUnicodeString(testArray[i][1]));
+ expectEqual(i + UnicodeString(": "), testStr, collectionToString(set), CharsToUnicodeString(testArray[i][1]));
}
} else {
- errln("Couldn't instantiate canonical iterator. Error: %s", u_errorName(status));
+ dataerrln("Couldn't instantiate canonical iterator. Error: %s", u_errorName(status));
}
delete set;
}
it.setSource(s, status);
- while (TRUE) {
+ for (;;) {
UnicodeString item = it.next();
if (item.isBogus()) break;
if (item == s) gotSource = TRUE;
int32_t i = 0;
const UHashElement *ne = NULL;
- int32_t el = -1;
+ int32_t el = UHASH_FIRST;
//Iterator it = basic.iterator();
ne = col->nextElement(el);
//while (it.hasNext())
logln("Testing CanonicalIterator::getSource");
logln("Instantiating canonical iterator with string "+start);
CanonicalIterator can(start, status);
+ if (U_FAILURE(status)) {
+ dataerrln("Error creating CanonicalIterator: %s", u_errorName(status));
+ return;
+ }
UnicodeString source = can.getSource();
logln("CanonicalIterator::getSource returned "+source);
if(start != source) {