rv = in->Read(buf2, 1, &cnt); if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) return rv; NS_ASSERTION(cnt == 0 && rv == NS_BASE_STREAM_WOULD_BLOCK, "Read failed");
printf("> should see OnClose message:\n");
TestPipeObserver(){    nsresult rv;    nsPipeObserver* obs = new nsPipeObserver();    if (obs == nsnull) return NS_ERROR_OUT_OF_MEMORY;    NS_ADDREF(obs);    printf("TestPipeObserver: OnWrite and OnFull should be called once, OnEmpty should be called twice.\n");    nsIInputStream* in;    nsIOutputStream* out;    rv = NS_NewPipe(&in, &out, 20, 20, PR_TRUE, PR_TRUE);    if (NS_FAILED(rv)) return rv;    rv = in->SetObserver(obs);    if (NS_FAILED(rv)) return rv;    rv = out->SetObserver(obs);    if (NS_FAILED(rv)) return rv;    char buf[] = "puirt a beul: a style of Gaelic vocal music intended for dancing.";    PRUint32 cnt;    // this should print OnWrite message:    rv = out->Write(buf, 20, &cnt);    if (NS_FAILED(rv)) return rv;    NS_ASSERTION(cnt == 20, "Write failed");    // this should print OnFull message:    rv = out->Write(buf + 20, 1, &cnt);    if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) return rv;    NS_ASSERTION(cnt == 0 && rv == NS_BASE_STREAM_WOULD_BLOCK, "Write failed");    char buf2[20];    rv = in->Read(buf2, 20, &cnt);    if (NS_FAILED(rv)) return rv;    NS_ASSERTION(cnt == 20, "Read failed");    NS_ASSERTION(nsCRT::strncmp(buf, buf2, 20) == 0, "Read wrong stuff");    // this should print OnEmpty message:    rv = in->Read(buf2, 1, &cnt);    if (NS_FAILED(rv) && rv != NS_BASE_STREAM_WOULD_BLOCK) return rv;    NS_ASSERTION(cnt == 0 && rv == NS_BASE_STREAM_WOULD_BLOCK, "Read failed");    NS_RELEASE(obs);    NS_RELEASE(in);    NS_RELEASE(out);    return NS_OK;}