本文整理汇总了C++中StringEnumeration::unext方法的典型用法代码示例。如果您正苦于以下问题:C++ StringEnumeration::unext方法的具体用法?C++ StringEnumeration::unext怎么用?C++ StringEnumeration::unext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringEnumeration
的用法示例。
在下文中一共展示了StringEnumeration::unext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkStringEnumeration
/**
* Iterate through the given iterator, checking to see that all the strings
* in the expected array are present.
* @param expected array of strings we expect to see, or NULL
* @param expectedCount number of elements of expected, or 0
*/
int32_t CollationServiceTest::checkStringEnumeration(const char* msg,
StringEnumeration& iter,
const char** expected,
int32_t expectedCount) {
UErrorCode ec = U_ZERO_ERROR;
U_ASSERT(expectedCount >= 0 && expectedCount < 31); // [sic] 31 not 32
int32_t i = 0, idxAfterReset = 0, n = iter.count(ec);
assertSuccess("count", ec);
UnicodeString buf, buffAfterReset;
int32_t seenMask = 0;
for (;; ++i) {
const UnicodeString* s = iter.snext(ec);
if (!assertSuccess("snext", ec) || s == NULL)
break;
if (i != 0)
buf.append(UNICODE_STRING_SIMPLE(", "));
buf.append(*s);
// check expected list
for (int32_t j=0, bit=1; j<expectedCount; ++j, bit<<=1) {
if ((seenMask&bit)==0) {
UnicodeString exp(expected[j], (char*)NULL);
if (*s == exp) {
seenMask |= bit;
logln((UnicodeString)"Ok: \"" + exp + "\" seen");
}
}
}
}
// can't get pesky operator+(const US&, foo) to cooperate; use toString
#if !UCONFIG_NO_FORMATTING
logln(UnicodeString() + msg + " = [" + buf + "] (" + toString(i) + ")");
#else
logln(UnicodeString() + msg + " = [" + buf + "] (??? NO_FORMATTING)");
#endif
assertTrue("count verified", i==n);
iter.reset(ec);
for (;; ++idxAfterReset) {
const UChar *s = iter.unext(NULL, ec);
if (!assertSuccess("unext", ec) || s == NULL)
break;
if (idxAfterReset != 0)
buffAfterReset.append(UNICODE_STRING_SIMPLE(", "));
buffAfterReset.append(s);
}
assertTrue("idxAfterReset verified", idxAfterReset==n);
assertTrue("buffAfterReset verified", buffAfterReset==buf);
// did we see all expected strings?
if (((1<<expectedCount)-1) != seenMask) {
for (int32_t j=0, bit=1; j<expectedCount; ++j, bit<<=1) {
if ((seenMask&bit)==0) {
errln((UnicodeString)"FAIL: \"" + expected[j] + "\" not seen");
}
}
}
return n;
}