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 (50 lines) | stat: -rw-r--r-- 1,534 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
#import "Testing.h"
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSString.h>

int main()
{
  NSAutoreleasePool   	*arp = [NSAutoreleasePool new];
  NSMutableArray 	*testObjs = [NSMutableArray array];
  NSDictionary 		*obj;

  test_alloc(@"NSDictionary");
  obj = [NSDictionary dictionary];
  [testObjs addObject: obj];
  PASS(obj != nil
    && [obj isKindOfClass: [NSDictionary class]]
    && [obj count] == 0,
    "can create an empty dictionary")

  obj = [NSDictionary dictionaryWithObject: @"Hello" forKey: @"Key"];
  [testObjs addObject: obj];
  PASS(obj != nil
    && [obj isKindOfClass: [NSDictionary class]]
    && [obj count] == 1, 
    "can create a dictionary with one element")
  
  test_NSObject(@"NSDictionary", testObjs);
  test_NSCoding(testObjs);
  test_keyed_NSCoding(testObjs);
  test_NSCopying(@"NSDictionary", @"NSMutableDictionary", testObjs, YES, NO);
  test_NSMutableCopying(@"NSDictionary", @"NSMutableDictionary", testObjs);
  START_SET("NSDictionary subscripting")
# ifndef __has_feature
# define __has_feature(x) 0
# endif
#if __has_feature(objc_subscripting)
  NSDictionary *dictionary = @{@123 : @123.4 ,
                               @"date" : @"today" };
  PASS([dictionary[@123] isEqual: @123.4], "Dictionary subscripting works")
# else
   SKIP("No dictionary subscripting support in the compiler.")
# endif
  END_SET("NSDictionary subscripting")


  [arp release]; arp = nil;
  return 0;
}