︙ | | | ︙ | |
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OTAppDelegate.h"
#import "OFColor.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFValue.h"
#import "OTTestCase.h"
#import "OTAssertionFailedException.h"
OF_APPLICATION_DELEGATE(OTAppDelegate)
static bool
isSubclassOfClass(Class class, Class superclass)
{
for (Class iter = class; iter != Nil; iter = class_getSuperclass(iter))
|
>
|
|
|
>
>
>
|
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
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFApplication.h"
#import "OFColor.h"
#import "OFDictionary.h"
#import "OFMethodSignature.h"
#import "OFSet.h"
#import "OFStdIOStream.h"
#import "OFValue.h"
#import "OTTestCase.h"
#import "OTAssertionFailedException.h"
@interface OTAppDelegate: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(OTAppDelegate)
static bool
isSubclassOfClass(Class class, Class superclass)
{
for (Class iter = class; iter != Nil; iter = class_getSuperclass(iter))
|
︙ | | | ︙ | |
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
return nil;
@try {
tests = [OFMutableSet set];
for (Method *iter = methods; *iter != NULL; iter++) {
SEL selector = method_getName(*iter);
if (selector == NULL)
continue;
if (strncmp(sel_getName(selector), "test", 4) == 0)
[tests addObject:
[OFValue valueWithPointer: selector]];
}
} @finally {
OFFreeMemory(methods);
}
[tests makeImmutable];
return tests;
}
- (void)printStatusForTest: (SEL)test
inClass: (Class)class
status: (int)status
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
return nil;
@try {
tests = [OFMutableSet set];
for (Method *iter = methods; *iter != NULL; iter++) {
SEL selector = method_getName(*iter);
void *pool;
OFMethodSignature *sig;
if (selector == NULL)
continue;
if (strncmp(sel_getName(selector), "test", 4) != 0)
continue;
pool = objc_autoreleasePoolPush();
sig = [OFMethodSignature signatureWithObjCTypes:
method_getTypeEncoding(*iter)];
if (strcmp(sig.methodReturnType, "v") == 0 &&
sig.numberOfArguments == 2 &&
strcmp([sig argumentTypeAtIndex: 0], "@") == 0 &&
strcmp([sig argumentTypeAtIndex: 1], ":") == 0)
[tests addObject:
[OFValue valueWithPointer: selector]];
objc_autoreleasePoolPop(pool);
}
} @finally {
OFFreeMemory(methods);
}
if (class_getSuperclass(class) != Nil)
[tests unionSet:
[self testsInClass: class_getSuperclass(class)]];
[tests makeImmutable];
return tests;
}
- (void)printStatusForTest: (SEL)test
inClass: (Class)class
status: (int)status
|
︙ | | | ︙ | |
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
[OFStdOut reset];
}
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFSet OF_GENERIC(Class) *testClasses = [self testClasses];
size_t numSucceeded = 0, numFailed = 0;
[OFStdOut writeFormat: @"Running %zu test case(s)\n",
testClasses.count];
for (Class class in testClasses) {
[OFStdOut setForegroundColor: [OFColor teal]];
[OFStdOut writeFormat: @"Running ", class];
[OFStdOut setForegroundColor: [OFColor aqua]];
[OFStdOut writeFormat: @"%@\n", class];
[OFStdOut reset];
for (OFValue *test in [self testsInClass: class]) {
|
>
>
>
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
[OFStdOut reset];
}
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
OFSet OF_GENERIC(Class) *testClasses = [self testClasses];
size_t numSucceeded = 0, numFailed = 0;
OFMutableDictionary *summaries = [OFMutableDictionary dictionary];
[OFStdOut writeFormat: @"Running %zu test case(s)\n",
testClasses.count];
for (Class class in testClasses) {
OFArray *summary;
[OFStdOut setForegroundColor: [OFColor teal]];
[OFStdOut writeFormat: @"Running ", class];
[OFStdOut setForegroundColor: [OFColor aqua]];
[OFStdOut writeFormat: @"%@\n", class];
[OFStdOut reset];
for (OFValue *test in [self testsInClass: class]) {
|
︙ | | | ︙ | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
description: nil];
numSucceeded++;
} else
numFailed++;
objc_autoreleasePoolPop(pool);
}
}
[OFStdOut setForegroundColor: [OFColor fuchsia]];
[OFStdOut writeFormat: @"%zu", numSucceeded];
[OFStdOut setForegroundColor: [OFColor purple]];
[OFStdOut writeString: @" test(s) succeeded, "];
[OFStdOut setForegroundColor: [OFColor fuchsia]];
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
description: nil];
numSucceeded++;
} else
numFailed++;
objc_autoreleasePoolPop(pool);
}
summary = [class summary];
if (summary != nil)
[summaries setObject: summary forKey: class];
}
for (Class class in summaries) {
OFArray *summary = [summaries objectForKey: class];
[OFStdOut setForegroundColor: [OFColor teal]];
[OFStdOut writeString: @"Summary for "];
[OFStdOut setForegroundColor: [OFColor aqua]];
[OFStdOut writeFormat: @"%@\n", class];
for (OFPair *line in summary) {
[OFStdOut setForegroundColor: [OFColor navy]];
[OFStdOut writeFormat: @"%@: ", line.firstObject];
[OFStdOut setForegroundColor: [OFColor blue]];
[OFStdOut writeFormat: @"%@\n", line.secondObject];
}
}
[OFStdOut setForegroundColor: [OFColor fuchsia]];
[OFStdOut writeFormat: @"%zu", numSucceeded];
[OFStdOut setForegroundColor: [OFColor purple]];
[OFStdOut writeString: @" test(s) succeeded, "];
[OFStdOut setForegroundColor: [OFColor fuchsia]];
|
︙ | | | ︙ | |