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 (41 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (7)
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
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSValue.h>

int main()
{
  NSAutoreleasePool   *arp = [NSAutoreleasePool new];
  NSNumber *testObj;

  test_alloc_only(@"NSNumber");
  testObj = [NSNumber numberWithInt: 5];
  test_NSObject(@"NSNumber", [NSArray arrayWithObject:testObj]);
  test_NSCoding([NSArray arrayWithObject:testObj]);
  test_NSCopying(@"NSNumber", @"NSNumber", 
       [NSArray arrayWithObject:testObj],YES,NO);
  {
     // For more paranoid testing, you can change this to int or long long.
     short i = 0;
     int increment = 1;
     while (i >= 0)
     {
       NSNumber *n = [[NSNumber alloc] initWithInt: i];
       PASS(i == [n intValue], "int -> NSNumber -> int is identity operation for %d", i);
       [n release];
       i += increment;
       if (i > 100) { increment++; }
     }
     i = -1;
     increment = 1;
     while (i <= 0)
       {
         NSNumber *n = [[NSNumber alloc] initWithInt: i];
         PASS(i == [n intValue], "int -> NSNumber -> int is identity operation for %d", i);
         [n release];
         i -= increment;
         if (i < -100) { increment++; }
       }
  }
  [arp release]; arp = nil;
  return 0;
}