cout << "\tFailed!! return value != NS_OK\n";
printf("\tFailed!! return value != NS_OK\n");
static void TestSort(nsILocale *locale, nsCollationStrength collationStrength, FILE *fp){  nsresult res;  nsICollationFactory *factoryInst;  nsICollation *collationInst;  nsCollationStrength strength;  collation_rec key_array[5];  PRUint8 *aKey;  PRUint32 aLength;  //nsString locale("en-US");  nsString string1("AAC");  nsString string2("aac");  nsString string3("AAC");  nsString string4("aac");  nsString string5("AAC");  nsString string_array[5];  cout << "==============================\n";  cout << "Start sort Test \n";  cout << "==============================\n";  res = nsComponentManager::CreateInstance(kCollationFactoryCID,                                           NULL,                                           NS_GET_IID(nsICollationFactory),                                           (void**) &factoryInst);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  res = factoryInst->CreateCollation(locale, &collationInst);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  // set collation strength  g_CollationStrength = collationStrength;  strength = g_CollationStrength;  if (fp != NULL) {    res = NS_ADDREF(collationInst);    SortTestFile(collationInst, fp);    NS_RELEASE(collationInst);    return;  }  cout << "==============================\n";  cout << "Sort Test by comparestring.\n";  cout << "==============================\n";  string_array[0] = string1;  string_array[1] = string2;  string_array[2] = string3;  string_array[3] = string4;  string_array[4] = string5;  cout << "print string before sort\n";  TestSortPrint1(string_array, 5);  g_collationInst = collationInst;  res = collationInst->AddRef();  qsort( (void *)string_array, 5, sizeof(nsString), compare1 );  res = collationInst->Release();  cout << "print string after sort\n";  TestSortPrint1(string_array, 5);  cout << "==============================\n";  cout << "Sort Test by collation key.\n";  cout << "==============================\n";  res = CreateCollationKey(collationInst, strength, string1, &aKey, &aLength);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  key_array[0].aKey = aKey;  key_array[0].aLength = aLength;  res = CreateCollationKey(collationInst, strength, string2, &aKey, &aLength);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  key_array[1].aKey = aKey;  key_array[1].aLength = aLength;  res = CreateCollationKey(collationInst, strength, string3, &aKey, &aLength);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  key_array[2].aKey = aKey;  key_array[2].aLength = aLength;  res = CreateCollationKey(collationInst, strength, string4, &aKey, &aLength);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  key_array[3].aKey = aKey;  key_array[3].aLength = aLength;  res = CreateCollationKey(collationInst, strength, string5, &aKey, &aLength);  if(NS_FAILED(res)) {    cout << "\tFailed!! return value != NS_OK\n";  }  key_array[4].aKey = aKey;  key_array[4].aLength = aLength;  cout << "print key before sort\n";  TestSortPrint2(key_array, 5);  g_collationInst = collationInst;  res = collationInst->AddRef();  qsort( (void *)key_array, 5, sizeof(collation_rec), compare2 );  res = collationInst->Release();  cout << "print key after sort\n";  TestSortPrint2(key_array, 5);  res = collationInst->Release();  res = factoryInst->Release();  for (int i = 0; i < 5; i++) {    delete [] key_array[i].aKey;  }  cout << "==============================\n";  cout << "Finish sort Test \n";  cout << "==============================\n";}