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 (56 lines) | stat: -rw-r--r-- 2,073 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
52
53
54
55
56
#import <Foundation/NSProgress.h>
#import <Foundation/NSThread.h>
#import <Foundation/NSAutoreleasePool.h>
#import "ObjectTesting.h"

int main()
{
  ENTER_POOL
  NSMutableDictionary *dict = [NSMutableDictionary dictionary];

  [dict setObject:@"value" forKey:@"key"];
  NSProgress *progress = AUTORELEASE([[NSProgress alloc] initWithParent: nil
							       userInfo: dict]);
  PASS(progress != nil,
    "[NSProgress initWithParent:userInfo:] returns instance");
  
  PASS_EQUAL([progress userInfo], dict,
    "[NSProgress userInfo] returns correct user info");
  
  [progress setUserInfoObject:@"new value" forKey:@"key"];
  PASS_EQUAL([[progress userInfo] objectForKey:@"key"], @"new value",
    "[NSProgress setUserInfoObject:forKey:] updates user info");
  
  progress = [NSProgress discreteProgressWithTotalUnitCount:100];
  PASS(progress != nil,
    "[NSProgress discreteProgressWithTotalUnitCount:] returns instance");
  
  progress = [NSProgress progressWithTotalUnitCount:100];
  PASS(progress != nil,
    "[NSProgress progressWithTotalUnitCount:] returns instance");
  
  progress = [NSProgress progressWithTotalUnitCount:100
                                             parent:progress
                                   pendingUnitCount:50];
  PASS(progress != nil,
    "[NSProgress progressWithTotalUnitCount:] returns instance");
  
  [progress becomeCurrentWithPendingUnitCount:50];
  NSProgress *currentProgress = [NSProgress currentProgress];
  PASS(currentProgress == progress,
    "Correct progress object associated with current thread");
  
  NSProgress *new_progress = [NSProgress progressWithTotalUnitCount:100
                                                             parent:progress
                                                   pendingUnitCount:50];
  [new_progress addChild: AUTORELEASE([[NSProgress alloc]
    initWithParent: nil userInfo: nil]) withPendingUnitCount:50];
  
  [currentProgress resignCurrent];

  PASS([NSProgress currentProgress] == nil,
    "Current progress is nil after resign current");

  LEAVE_POOL
  return 0;
}