+
+ status = U_ZERO_ERROR;
+ unum = unum_open(UNUM_CURRENCY, NULL, 0, "en_US", NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_data_err("unum_open UNUM_CURRENCY for en_US fails with %s\n", u_errorName(status));
+ } else {
+ unum_setAttribute(unum, UNUM_MIN_INTEGER_DIGITS, 0);
+ unum_setAttribute(unum, UNUM_MIN_FRACTION_DIGITS, 0);
+ minInt = unum_getAttribute(unum, UNUM_MIN_INTEGER_DIGITS);
+ minFrac = unum_getAttribute(unum, UNUM_MIN_FRACTION_DIGITS);
+ if (minInt != 0 || minFrac != 0) {
+ log_err("after setting CURRENCY minInt=minFrac=0, get minInt %d, minFrac %d\n", minInt, minFrac);
+ }
+
+ status = U_ZERO_ERROR;
+ ulen = unum_formatDouble(unum, 10.0, ubuf, kUBufMax, NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_err("unum_formatDouble (CURRRENCY) 10.0 ulen %d fails with %s\n", ulen, u_errorName(status));
+ } else if (u_strcmp(ubuf, u"$10") != 0) {
+ u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status);
+ log_err("unum_formatDouble (CURRRENCY) 10.0 expected \"$10\", got \"%s\"\n", bbuf);
+ }
+
+ status = U_ZERO_ERROR;
+ ulen = unum_formatDouble(unum, 0.9, ubuf, kUBufMax, NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_err("unum_formatDouble (CURRRENCY) 0.9 ulen %d fails with %s\n", ulen, u_errorName(status));
+ } else if (u_strcmp(ubuf, u"$.9") != 0) {
+ u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status);
+ log_err("unum_formatDouble (CURRRENCY) 0.9 expected \"$.9\", got \"%s\"\n", bbuf);
+ }
+
+ status = U_ZERO_ERROR;
+ ulen = unum_formatDouble(unum, 0.0, ubuf, kUBufMax, NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_err("unum_formatDouble (CURRRENCY) 0.0 ulen %d fails with %s\n", ulen, u_errorName(status));
+ } else if (u_strcmp(ubuf, u"$0") != 0) {
+ u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status);
+ log_err("unum_formatDouble (CURRRENCY) 0.0 expected \"$0\", got \"%s\"\n", bbuf);
+ }
+
+ unum_close(unum);
+ }
+
+ // addition for rdar://57291456
+ status = U_ZERO_ERROR;
+ unum = unum_open(UNUM_PATTERN_DECIMAL, NULL, 0, "en_IE", NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_data_err("unum_open UNUM_DECIMAL for en_US fails with %s\n", u_errorName(status));
+ } else {
+ unum_setAttribute(unum, UNUM_MIN_INTEGER_DIGITS, 0);
+ unum_setAttribute(unum, UNUM_MAX_FRACTION_DIGITS, 1);
+ minInt = unum_getAttribute(unum, UNUM_MIN_INTEGER_DIGITS);
+ maxFrac = unum_getAttribute(unum, UNUM_MAX_FRACTION_DIGITS);
+ if (minInt != 0 || maxFrac != 1) {
+ log_err("after setting minInt=0, maxFrac=1, get minInt %d, maxFrac %d\n", minInt, maxFrac);
+ }
+
+ status = U_ZERO_ERROR;
+ ulen = unum_formatDouble(unum, 0.0, ubuf, kUBufMax, NULL, &status);
+ if ( U_FAILURE(status) ) {
+ log_err("unum_formatDouble (maxFrac 1) 0.0 ulen %d fails with %s\n", ulen, u_errorName(status));
+ } else if (u_strcmp(ubuf, u".0") != 0) {
+ u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status);
+ log_err("unum_formatDouble (maxFrac 1) 0.0 expected \".0\", got \"%s\"\n", bbuf);
+ }
+
+ unum_close(unum);
+ }