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 (38 lines) | stat: -rw-r--r-- 1,274 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
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSArray.h>

int main()
{
  NSAutoreleasePool   *arp = [NSAutoreleasePool new];
  NSArray *testObj = [NSMutableArray arrayWithCapacity:1];
  test_alloc(@"NSMutableArray");
  test_NSObject(@"NSMutableArray", [NSArray arrayWithObject:testObj]); 
  test_NSCoding([NSArray arrayWithObject:testObj]); 
  test_keyed_NSCoding([NSArray arrayWithObject:testObj]); 
  test_NSCopying(@"NSArray",@"NSMutableArray", 
                 [NSArray arrayWithObject:testObj], NO, NO); 
  test_NSMutableCopying(@"NSArray",@"NSMutableArray", 
                 [NSArray arrayWithObject:testObj]); 

NSMutableString *str1, *str2;
 unichar chars[3];

 chars[0] = '\"';
 chars[1] = 1;
 str1 = [NSMutableString stringWithCharacters: chars length: 2];
 [str1 replaceOccurrencesOfString: @"\""
                      withString: @"\\\""
                         options: 0
                           range: NSMakeRange(0, [str1 length])];

 chars[0] = '\\';
 chars[1] = '\"';
 chars[2] = 1;
 str2 = [NSMutableString stringWithCharacters: chars length: 3];
 NSLog(@"string 1 %@ string 2 %@", str1, str2);
 PASS([str1 isEqual: str2],
   "string occurrences replacement works");
  [arp release]; arp = nil;
  return 0;
}