explicitlySetAttributes(0),
actualLocaleIsSameAsValid(FALSE) {
if(U_FAILURE(errorCode)) { return; }
- if(bin == NULL || length <= 0 || base == NULL) {
+ if(bin == NULL || length == 0 || base == NULL) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
* cloneBinary. Binary image used in instantiation of the
* collator remains owned by the user and should stay around for
* the lifetime of the collator. The API also takes a base collator
- * which usually should be the root collator.
+ * which must be the root collator.
* @param bin binary image owned by the user and required through the
* lifetime of the collator
* @param length size of the image. If negative, the API will try to
* figure out the length of the image
- * @param base fallback collator, usually root. The base is required to be
- * present through the lifetime of the collator. Currently
- * it cannot be NULL.
+ * @param base Base collator, for lookup of untailored characters.
+ * Must be the root collator, must not be NULL.
+ * The base is required to be present through the lifetime of the collator.
* @param status for catching errors
* @return newly created collator
* @see cloneBinary
* ucol_cloneBinary. Binary image used in instantiation of the
* collator remains owned by the user and should stay around for
* the lifetime of the collator. The API also takes a base collator
- * which usually should be the root collator.
+ * which must be the root collator.
* @param bin binary image owned by the user and required through the
* lifetime of the collator
* @param length size of the image. If negative, the API will try to
* figure out the length of the image
- * @param base fallback collator, usually the root collator. Base is required to be
- * present through the lifetime of the collator. Currently
- * it cannot be NULL.
+ * @param base Base collator, for lookup of untailored characters.
+ * Must be the root collator, must not be NULL.
+ * The base is required to be present through the lifetime of the collator.
* @param status for catching errors
* @return newly created collator
* @see ucol_cloneBinary
int32_t bin2Length = rbc2.cloneBinary(bin2, LENGTHOF(bin2), errorCode);
assertEquals("len(rbc binary)==len(rbc2 binary)", binLength, bin2Length);
assertTrue("rbc binary==rbc2 binary", binLength == bin2Length && memcmp(bin, bin2, binLength) == 0);
+
+ RuleBasedCollator rbc3(bin, -1, rbRoot, errorCode);
+ if(errorCode.logDataIfFailureAndReset("RuleBasedCollator(rbc binary, length<0)")) {
+ return;
+ }
+ assertEquals("rbc3.strength==primary", UCOL_PRIMARY, rbc3.getAttribute(UCOL_STRENGTH, errorCode));
+ assertEquals("rbc3: u-umlaut==ue", UCOL_EQUAL, rbc3.compare(uUmlaut, ue, errorCode));
+ assertTrue("rbc==rbc3", *rbc == rbc3);
}
void CollationAPITest::TestIterNumeric() {