diff --git a/Testing/nsnotification.m b/Testing/nsnotification.m index 85e620dca..bb9587512 100644 --- a/Testing/nsnotification.m +++ b/Testing/nsnotification.m @@ -6,6 +6,7 @@ #include #include +#include @interface Observer : NSObject - (void) gotNotificationFoo: not; @@ -31,6 +32,9 @@ int main () { id o1 = [NSObject new]; id observer1 = [Observer new]; + id arp; + + arp = [NSAutoreleasePool new]; [[NSNotificationCenter defaultCenter] addObserver: observer1 @@ -44,6 +48,7 @@ int main () name: foo object: nil]; + /* This will cause two messages to be printed, one for each request above. */ [[NSNotificationCenter defaultCenter] postNotificationName: foo @@ -54,5 +59,26 @@ int main () postNotificationName: foo object: nil]; + + [[NSNotificationCenter defaultCenter] + removeObserver: observer1 + name: nil + object: o1]; + + /* This will cause message to be printed. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + + [[NSNotificationCenter defaultCenter] + removeObserver: observer1]; + + /* This will cause no messages to be printed. */ + [[NSNotificationCenter defaultCenter] + postNotificationName: foo + object: o1]; + + [arp release]; + exit (0); }