99#import " QiniuSDK.h"
1010#import < XCTest/XCTest.h>
1111
12- @interface Demo : NSObject
13- @property (nonatomic , copy ) NSString *title;
14- @property (nonatomic , strong ) NSLock *locker;
15- @property (nonatomic , strong ) NSArray *object;
16- @end
17- @implementation Demo
18- -(instancetype )init {
19- if (self = [super init ]) {
20- self.locker = [[NSLock alloc ] init ];
21- }
22- return self;
23- }
24- -(NSArray *)object {
25- // [self.locker lock];
26- if (_object == nil ) {
27- _object = @[self .title];
28- }
29- // [self.locker unlock];
30- return _object;
31- }
32- @end
3312@interface QNBase64Test : XCTestCase
3413
3514@end
@@ -43,36 +22,6 @@ - (void)testEncode {
4322 XCTAssert ([encode isEqual: @" 5L2g5aW9Lys9" ], @" encode: %@ " , encode);
4423}
4524
46-
47- - (void )testA {
48- for (int i=0 ; i<1000 ; i++) {
49- Demo *demo = [[Demo alloc ] init ];
50- __weak Demo *weak = demo;
51- void (^create)(int ) = ^(int index) {
52- __strong Demo *strong = weak;
53- // Demo *strong = demo;
54- int ip = index;
55- NSLog (@" >> %d " ,ip);
56- strong.title = [NSString stringWithFormat: @" == %d ==" , ip];
57- NSLog (@" << %@ :%d " , strong.object , ip);
58- NSLog (@" << %@ :%lu :%d " , strong.object , (unsigned long )[strong.object count ], ip);
59- };
60-
61- dispatch_group_t group = dispatch_group_create ();
62- for (int j=0 ; j<10 ; j++) {
63- dispatch_group_enter (group);
64- dispatch_group_async (group, dispatch_get_global_queue (0 , 0 ), ^{
65- dispatch_group_leave (group);
66- create (j);
67- });
68- }
69-
70- dispatch_group_wait (group, DISPATCH_TIME_FOREVER);
71-
72- NSLog (@" == \n\n ==" );
73- }
74- }
75-
7625@end
7726
7827
0 commit comments