nsIObserver *aObserver = new TestObserver("Observer-A");
nsIObserver *aObserver = new TestObserver(NS_ConvertASCIItoUCS2("Observer-A"));
int main(int argc, char *argv[]){    nsString topicA( "topic-A" );    nsString topicB( "topic-B" );    nsresult rv;    nsresult res = nsComponentManager::CreateInstance(NS_OBSERVERSERVICE_PROGID,                                                NULL,                                                 NS_GET_IID(nsIObserverService),                                                (void **) &anObserverService);	    if (res == NS_OK) {        nsIObserver *anObserver;        nsIObserver *aObserver = new TestObserver("Observer-A");        aObserver->AddRef();        nsIObserver *bObserver = new TestObserver("Observer-B");        bObserver->AddRef();                    cout << "Adding Observer-A as observer of topic-A..." << endl;        rv = anObserverService->AddObserver(aObserver, topicA.GetUnicode());        testResult(rv);         cout << "Adding Observer-B as observer of topic-A..." << endl;        rv = anObserverService->AddObserver(bObserver, topicA.GetUnicode());        testResult(rv);         cout << "Adding Observer-B as observer of topic-B..." << endl;        rv = anObserverService->AddObserver(bObserver, topicB.GetUnicode());        testResult(rv);        cout << "Testing Notify(observer-A, topic-A)..." << endl;        rv = anObserverService->Notify( aObserver,                                   topicA.GetUnicode(),                                   nsString("Testing Notify(observer-A, topic-A)").GetUnicode() );        testResult(rv);        cout << "Testing Notify(observer-B, topic-B)..." << endl;        rv = anObserverService->Notify( bObserver,                                   topicB.GetUnicode(),                                   nsString("Testing Notify(observer-B, topic-B)").GetUnicode() );        testResult(rv);         cout << "Testing EnumerateObserverList (for topic-A)..." << endl;        nsIEnumerator* e;        rv = anObserverService->EnumerateObserverList(topicA.GetUnicode(), &e);        testResult(rv);        cout << "Enumerating observers of topic-A..." << endl;        if ( NS_SUCCEEDED( rv ) ) {            nsISupports *inst;                for (e->First(); e->IsDone() != NS_OK; e->Next()) {                rv = e->CurrentItem(&inst);                if (NS_SUCCEEDED(rv)) {                  rv = inst->QueryInterface(NS_GET_IID(nsIObserver),(void**)&anObserver);                  cout << "Calling observe on enumerated observer "                        << NS_REINTERPRET_CAST(TestObserver*, NS_REINTERPRET_CAST(void*, inst))->mName << "..." << endl;                  rv = anObserver->Observe( inst, topicA.GetUnicode(), nsString("during enumeration").GetUnicode() );                  testResult(rv);                }            }        }        cout << "...done enumerating observers of topic-A" << endl;        cout << "Removing Observer-A..." << endl;        rv = anObserverService->RemoveObserver(aObserver, topicA.GetUnicode());        testResult(rv);        cout << "Removing Observer-B (topic-A)..." << endl;        rv = anObserverService->RemoveObserver(bObserver, topicB.GetUnicode());        testResult(rv);        cout << "Removing Observer-B (topic-B)..." << endl;        rv = anObserverService->RemoveObserver(bObserver, topicA.GetUnicode());        testResult(rv);           }    return NS_OK;}