nsAutoString buf; multi->GetItemAt(buf, i); char * str = buf.ToNewCString();
nsAutoString buf2; multi->GetItemAt(buf2, i); char * str = buf2.ToNewCString();
void multiListSelfTest(FILE * fd, char * aTitle, nsIListBox * listBox) {  fprintf(fd, "\n\n-----------------------------\n");  fprintf(fd, "%s self test\n", aTitle);  fprintf(fd, "-----------------------------\n\n");fflush(fd);  nsIListBox * multi = (nsIListBox*)listBox;  int inx = 4;  char * item4 = "Multi List Item 4";  nsAutoString buf;  char * selStr;  multi->GetItemAt(buf, 4);  selStr = buf.ToNewCString();  fprintf(fd, "\nTesting GetItemAt\n\tItem %d should be [%s] is [%s]  Test: [%s]\n", inx, item4, selStr,           eval(strcmp(selStr, item4) == 0)); fflush(fd);  if (nsnull != selStr) delete[] selStr;  multi->Deselect();  int count = multi->GetSelectedCount();  fprintf(fd, "\nTesting Deselect\n\tCount %d Test: [%s]\n", count, eval(0 == count)); fflush(fd);  PRInt32 inxs[] = {0,2,4};  PRInt32 len = 3;  int i;  /*for (i=0;i<len;i++) {    multi->SelectItem(inxs[i]);  }*/  multi->SetSelectedIndices(inxs, 3);  fprintf(fd, "\nTesting selecting items 0,2,4\n");fflush(fd);  /*char * item0 = "Multi List Item 0";  nsString selItem;  multi->GetSelectedItem(selItem);  selStr = selItem.ToNewCString();  fprintf(fd, "\nTesting GetSelectedItem\n\t is [%s] should be [%s] Test: [%s]\n",     selStr, item0,  eval(!strcmp(selStr, item0))); fflush(fd);  if (nsnull != selStr) delete[] selStr;*/   int status = 1;  count = multi->GetSelectedCount();  fprintf(fd, "\nTesting GetSelectedCount\n\tCount [%d] should be [%d] Test: [%s]\n", count, len,           eval(len == count)); fflush(fd);  if (count == len) {    PRInt32 indices[256];    multi->GetSelectedIndices(indices, 256);    for (i=0;i<count;i++) {      if (indices[i] != inxs[i]) {        status = 0;        break;      }    }  } else {    status = 0;  }  if (status == 1) {    fprintf(fd, "\nTesting GetSelectedIndices\n\tTest: [%s]\n", eval(len == (int)multi->GetSelectedCount())); fflush(fd);  }  for (i=0;i<(int)multi->GetItemCount();i++) {    nsAutoString buf;    multi->GetItemAt(buf, i);    char * str = buf.ToNewCString();    fprintf(fd, "Item %d [%s]\n", i, str);fflush(fd);    if (nsnull != str) delete[] str;  }  fprintf(fd, "Removing Item #4\n");fflush(fd);  multi->RemoveItemAt(4);  nsString item4string(item4);  fprintf(fd, "\nTesting RemoveItemAt\n\tTest: [%s]\n", eval(-1 == (int)multi->FindItem(item4string, (PRInt32)0))); fflush(fd);  for (i=0;i<(int)multi->GetItemCount();i++) {    nsAutoString buf;    multi->GetItemAt(buf, i);    char * str = buf.ToNewCString();    fprintf(fd, "Item %d [%s]\n", i, str);fflush(fd);    if (nsnull != str) delete[] str;  }  fprintf(fd, "Done with Mulitple List Box\n");}