cout << "case insensitive comparison (string1 vs string2): " << result << "\n";
printf("case insensitive comparison (string1 vs string2): %d\n", result);
static void TestCollation(nsILocale *locale){//   nsString locale("en-US");   nsICollationFactory *f = NULL;   nsICollation *t = NULL;   nsresult res;   cout << "==============================\n";   cout << "Start nsICollation Test \n";   cout << "==============================\n";      res = nsComponentManager::CreateInstance(kCollationFactoryCID,                                            NULL,                                            NS_GET_IID(nsICollationFactory),                                            (void**) &f);              cout << "Test 1 - CreateInstance():\n";   if(NS_FAILED(res) || ( f == NULL ) ) {     cout << "\t1st CreateInstance failed\n";   } else {     f->Release();   }   res = nsComponentManager::CreateInstance(kCollationFactoryCID,                                            NULL,                                            NS_GET_IID(nsICollationFactory),                                            (void**) &f);   if(NS_FAILED(res) || ( f == NULL ) ) {     cout << "\t2nd CreateInstance failed\n";   }   res = f->CreateCollation(locale, &t);              if(NS_FAILED(res) || ( t == NULL ) ) {     cout << "\tCreateCollation failed\n";   } else {     nsString string1("abcde");     nsString string2("ABCDE");     nsString string3("xyz");     nsString string4("abc");     PRUint32 keyLength1, keyLength2, keyLength3;     PRUint8 *aKey1, *aKey2, *aKey3;     PRUint32 i;     PRInt32 result;      cout << "String data used:\n";      cout << "string1: ";      DebugDump(string1, cout);      cout << "string2: ";      DebugDump(string2, cout);      cout << "string3: ";      DebugDump(string3, cout);      cout << "string4: ";      DebugDump(string4, cout);      cout << "Test 2 - CompareString():\n";      res = t->CompareString(kCollationCaseInSensitive, string1, string2, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case insensitive comparison (string1 vs string2): " << result << "\n";      res = t->CompareString(kCollationCaseSensitive, string1, string2, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive comparison (string1 vs string2): " << result << "\n";      cout << "Test 3 - GetSortKeyLen():\n";      res = t->GetSortKeyLen(kCollationCaseSensitive, string2, &keyLength1);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "keyLength: " << keyLength1 << "\n";      cout << "Test 4 - CreateRawSortKey():\n";      aKey1 = (PRUint8 *) new PRUint8[keyLength1];      if (NULL == aKey1) {        cout << "\tFailed!! memory allocation failed.\n";      }      res = t->CreateRawSortKey(kCollationCaseSensitive, string2, aKey1, &keyLength1);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive key creation:\n";      cout << "keyLength: " << keyLength1 << "\n";      DebugDump(string2, cout);      cout.flush();      for (i = 0; i < keyLength1; i++) {        printf("%.2x ", aKey1[i]);        //cout << "key[" << i << "]: " << aKey1[i] << " ";      }      cout << "\n";      res = CreateCollationKey(t, kCollationCaseInSensitive, string2, &aKey2, &keyLength2);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case insensitive key creation:\n";      cout << "keyLength: " << keyLength2 << "\n";      DebugDump(string2, cout);      cout.flush();      for (i = 0; i < keyLength2; i++) {       printf("%.2x ", aKey2[i]);       //cout << "key[" << i << "]: " << aKey2[i] << " ";      }      cout << "\n";      cout << "Test 5 - CompareRawSortKey():\n";      res = CreateCollationKey(t, kCollationCaseSensitive, string1, &aKey3, &keyLength3);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      res = t->CompareRawSortKey(aKey1, keyLength1, aKey3, keyLength3, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive comparison (string1 vs string2): " << result << "\n";      res = t->CompareRawSortKey(aKey3, keyLength3, aKey1, keyLength1, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive comparison (string2 vs string1): " << result << "\n";      res = t->CompareRawSortKey(aKey2, keyLength2, aKey3, keyLength3, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case insensitive comparison (string1 vs string2): " << result << "\n";      if (NULL != aKey1)        delete[] aKey1;       if (NULL != aKey2)        delete[] aKey2;       if (NULL != aKey3)        delete[] aKey3;       res = CreateCollationKey(t, kCollationCaseSensitive, string1, &aKey1, &keyLength1);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      res = CreateCollationKey(t, kCollationCaseSensitive, string3, &aKey2, &keyLength2);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      res = CreateCollationKey(t, kCollationCaseSensitive, string4, &aKey3, &keyLength3);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      res = t->CompareRawSortKey(aKey1, keyLength1, aKey2, keyLength2, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive comparison (string1 vs string3): " << result << "\n";      res = t->CompareRawSortKey(aKey1, keyLength1, aKey3, keyLength3, &result);      if(NS_FAILED(res)) {        cout << "\tFailed!! return value != NS_OK\n";      }      cout << "case sensitive comparison (string1 vs string4): " << result << "\n";      if (NULL != aKey1)        delete[] aKey1;       if (NULL != aKey2)        delete[] aKey2;       if (NULL != aKey3)        delete[] aKey3;      res = t->Release();     res = f->Release();   }   cout << "==============================\n";   cout << "Finish nsICollation Test \n";   cout << "==============================\n";}