Bug 392493 - "Add forget() method to nsCOMPtr and nsRefPtr". r=dbaron.

This commit is contained in:
bent.mozilla@gmail.com 2007-10-03 17:57:09 -07:00
parent 01461fbe76
commit 0f82960824
2 changed files with 19 additions and 1 deletions

View File

@ -404,6 +404,15 @@ int main()
printf("Should destroy 3 |TestObject|s:\n");
}
{
printf("Should create one |TestRefObject|:\n");
nsRefPtr<TestRefObject> pobj( new TestRefObject() );
printf("Should do nothing:\n");
nsRefPtr<TestRefObject> pobj2( pobj.forget() );
printf("Should destroy one |TestRefObject|:\n");
}
printf("\nTesting construction.\n");
{

View File

@ -626,6 +626,15 @@ main()
printf("### End Test 23\n");
{
printf("\n### setup for Test 24\n");
nsCOMPtr<IFoo> fooP( do_QueryInterface(new IFoo) );
printf("### Test 24: does |forget| avoid an AddRef/Release when assigning to another nsCOMPtr?\n");
nsCOMPtr<IFoo> fooP2( fooP.forget() );
}
printf("### End Test 24\n");
{
nsCOMPtr<IFoo> fooP;
@ -643,7 +652,7 @@ main()
}
printf("\n### Test 24: will a static |nsCOMPtr| |Release| before program termination?\n");
printf("\n### Test 25: will a static |nsCOMPtr| |Release| before program termination?\n");
gFoop = do_QueryInterface(new IFoo);
printf("<<main()\n");