File: basic.m

package info (click to toggle)
gnustep-base 1.31.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,580 kB
  • sloc: objc: 239,446; ansic: 36,519; cpp: 122; sh: 112; makefile: 100; xml: 32
file content (51 lines) | stat: -rw-r--r-- 1,690 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#import <Foundation/NSNotification.h>
#import <Foundation/NSAutoreleasePool.h>
#import "ObjectTesting.h"

@implementation NSNotification (Testing)
- (BOOL) isEqualForTestcase: (id)other
{
  if (NO == [other isKindOfClass: [NSNotification class]])
    return NO;
  if ([self name] != [other name]
    && NO == [[self name] isEqual: [other name]])
    return NO;
  if ([self object] != [other object]
    && NO == [[self object] isEqual: [other object]])
    return NO;
  if ([self userInfo] != [other userInfo]
    && NO == [[self userInfo] isEqual: [other userInfo]])
    return NO;
  return YES;
}
@end

int main()
{
  ENTER_POOL
  NSNotification 	*obj;
  NSMutableArray 	*testObjs = [NSMutableArray array];
  NSDictionary          *info = [NSDictionary dictionaryWithObjectsAndKeys:
    @"obj", @"key", nil];
  NSNotification        *o1 = [NSNotification notificationWithName: @"hello"
                                                            object: @"there"
                                                          userInfo: info]; 
  NSNotification        *o2 = [NSNotification notificationWithName: @"hello"
                                                            object: @"there"
                                                          userInfo: info]; 

  PASS([o1 hash] == [o2 hash], "equal notification hashes")
  PASS_EQUAL(o1, o2, "equal notifications")

  test_alloc(@"NSNotification"); 

  obj = AUTORELEASE([NSNotification new]);
  [testObjs addObject: obj];
  test_NSObject(@"NSNotification", testObjs);
  test_NSCoding(testObjs);
  test_keyed_NSCoding(testObjs);
  test_NSCopying(@"NSNotification",@"NSNotification",testObjs,NO,NO);
  
  LEAVE_POOL
  return 0;
}