|
8 | 8 | context(@"when use serial queue", ^{ |
9 | 9 | it(@"run async operation in series", ^{ |
10 | 10 | __block NSString *testString = @""; |
11 | | - NSOperationQueue *testOperationQueue = [[NSOperationQueue alloc]init]; |
| 11 | + NSOperationQueue *testOperationQueue = [NSOperationQueue new]; |
12 | 12 | testOperationQueue.maxConcurrentOperationCount = 1; |
13 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 13 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
14 | 14 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
15 | 15 | testString = [testString stringByAppendingString:@"1"]; |
16 | 16 | finish(); |
17 | 17 | }); |
18 | 18 | }]; |
19 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 19 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
20 | 20 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
21 | 21 | testString = [testString stringByAppendingString:@"2"]; |
22 | 22 | finish(); |
23 | 23 | }); |
24 | 24 | }]; |
25 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 25 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
26 | 26 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
27 | 27 | testString = [testString stringByAppendingString:@"3"]; |
28 | 28 | finish(); |
|
34 | 34 | context(@"when use parallel queue", ^{ |
35 | 35 | it(@"run async operation in parallel", ^{ |
36 | 36 | __block NSString *testString = @""; |
37 | | - NSOperationQueue *testOperationQueue = [[NSOperationQueue alloc]init]; |
| 37 | + NSOperationQueue *testOperationQueue = [NSOperationQueue new]; |
38 | 38 | testOperationQueue.maxConcurrentOperationCount = 3; |
39 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 39 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
40 | 40 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
41 | 41 | testString = [testString stringByAppendingString:@"1"]; |
42 | 42 | finish(); |
43 | 43 | }); |
44 | 44 | }]; |
45 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 45 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
46 | 46 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
47 | 47 | testString = [testString stringByAppendingString:@"2"]; |
48 | 48 | finish(); |
49 | 49 | }); |
50 | 50 | }]; |
51 | | - [testOperationQueue addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
| 51 | + [testOperationQueue of_addOperationWithAsyncBlock:^(OFAsyncBlockFinish _Nonnull finish) { |
52 | 52 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
53 | 53 | testString = [testString stringByAppendingString:@"3"]; |
54 | 54 | finish(); |
|
64 | 64 | NSString *testString = @"This is test string."; |
65 | 65 | it(@"match regex", ^{ |
66 | 66 | NSString *testRegex = @".*"; |
67 | | - expect(@([testString matchRegex:testRegex])).to(beTrue()); |
| 67 | + expect(@([testString of_matchRegex:testRegex])).to(beTrue()); |
68 | 68 | }); |
69 | 69 |
|
70 | 70 | it(@"has first match of regex", ^{ |
71 | 71 | NSString *testRegex = @"is"; |
72 | | - expect([testString firstMatchOfRegex:testRegex]).toNot(beNil()); |
| 72 | + expect([testString of_firstMatchOfRegex:testRegex]).toNot(beNil()); |
73 | 73 | }); |
74 | 74 |
|
75 | 75 | it(@"has all matches of regex", ^{ |
76 | 76 | NSString *testRegex = @"is"; |
77 | 77 | NSInteger resultCount = 2; |
78 | | - expect(@([testString allMatchesOfRegex:testRegex].count)).to(equal(@(resultCount))); |
| 78 | + expect(@([testString of_allMatchesOfRegex:testRegex].count)).to(equal(@(resultCount))); |
79 | 79 | }); |
80 | 80 |
|
81 | 81 | it(@"has match email", ^{ |
82 | 82 | NSString *testEmail = @"test@mail.com"; |
83 | | - expect(@([testEmail matchEmailString])).to(beTrue()); |
| 83 | + expect(@([testEmail of_matchEmailString])).to(beTrue()); |
84 | 84 | }); |
85 | 85 | }); |
86 | 86 | context(@"when the string NOT contains regex pattern", ^{ |
87 | 87 | NSString *testString = @"This is test string."; |
88 | 88 | it(@"not match regex", ^{ |
89 | 89 | NSString *testRegex = @"This"; |
90 | | - expect(@([testString matchRegex:testRegex])).toNot(beTrue()); |
| 90 | + expect(@([testString of_matchRegex:testRegex])).toNot(beTrue()); |
91 | 91 | }); |
92 | 92 | it(@"has not first match of regex", ^{ |
93 | 93 | NSString *testRegex = @"testing"; |
94 | | - expect([testString firstMatchOfRegex:testRegex]).to(beNil()); |
| 94 | + expect([testString of_firstMatchOfRegex:testRegex]).to(beNil()); |
95 | 95 | }); |
96 | 96 |
|
97 | 97 | it(@"has not all matches of regex", ^{ |
98 | 98 | NSString *testRegex = @"testing"; |
99 | | - expect([testString firstMatchOfRegex:testRegex]).to(beNil()); |
| 99 | + expect([testString of_firstMatchOfRegex:testRegex]).to(beNil()); |
100 | 100 | }); |
101 | 101 |
|
102 | 102 | it(@"has not match email", ^{ |
103 | 103 | NSString *testEmail = @"testmail.com"; |
104 | | - expect(@([testEmail matchEmailString])).toNot(beTrue()); |
| 104 | + expect(@([testEmail of_matchEmailString])).toNot(beTrue()); |
105 | 105 | }); |
106 | 106 | }); |
107 | 107 | }); |
|
111 | 111 | it(@"create color", ^{ |
112 | 112 | NSString *testStringColor = @"#e74c3c"; |
113 | 113 | CGFloat testR = 231/256.0f, testG = 76/256.0f, testB = 60/256.0f; |
114 | | - UIColor *testColor = [UIColor colorWithHexString:testStringColor]; |
| 114 | + UIColor *testColor = [UIColor of_colorWithHexString:testStringColor]; |
115 | 115 | CGFloat r, g, b; |
116 | 116 | [testColor getRed:&r green:&g blue:&b alpha:NULL]; |
117 | 117 | expect(@(r)).to(equal(@(testR))); |
|
121 | 121 | context(@"when NOT valid hex string", ^{ |
122 | 122 | it(@"create NIL color", ^{ |
123 | 123 | NSString *testStringColor = @"888e74c3c"; |
124 | | - expect([UIColor colorWithHexString:testStringColor]).to(beNil()); |
| 124 | + expect([UIColor of_colorWithHexString:testStringColor]).to(beNil()); |
125 | 125 | }); |
126 | 126 | }); |
127 | 127 |
|
|
0 commit comments