Ejemplo n.º 1
0
static jint ICU_getCurrencyNumericCode(JNIEnv* env, jclass, jstring javaCurrencyCode) {
  ScopedJavaUnicodeString currencyCode(env, javaCurrencyCode);
  if (!currencyCode.valid()) {
    return 0;
  }
  UnicodeString icuCurrencyCode(currencyCode.unicodeString());
  return ucurr_getNumericCode(icuCurrencyCode.getTerminatedBuffer());
}
Ejemplo n.º 2
0
static void TestNumericCode(void) {
    UChar code[4];
    int32_t i;
    int32_t numCode;

    for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) {
        u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, sizeof(code)/sizeof(code[0]));
        numCode = ucurr_getNumericCode(code);
        if (numCode != NUMCODE_TESTDATA[i].numericCode) {
            log_data_err("Error: ucurr_getNumericCode returned %d for currency %s, expected - %d\n",
                numCode, NUMCODE_TESTDATA[i].alphaCode, NUMCODE_TESTDATA[i].numericCode);
        }
    }
}
Ejemplo n.º 3
0
static void TestNumericCode(void) {
    UChar code[8];  // at least one longer than the longest alphaCode
    int32_t i;
    int32_t numCode;

    for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) {
        int32_t length = uprv_strlen(NUMCODE_TESTDATA[i].alphaCode);
        u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, length + 1);  // +1 includes the NUL
        numCode = ucurr_getNumericCode(code);
        if (numCode != NUMCODE_TESTDATA[i].numericCode) {
            log_data_err("Error: ucurr_getNumericCode returned %d for currency %s, expected - %d\n",
                numCode, NUMCODE_TESTDATA[i].alphaCode, NUMCODE_TESTDATA[i].numericCode);
        }
    }
}