Skip to content
Newer
Older
100644 761 lines (691 sloc) 45.2 KB
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
1 //
2 // GBCommentsProcessor-PreprocessingTesting.m
3 // appledoc
4 //
5 // Created by Tomaz Kragelj on 14.2.11.
6 // Copyright (C) 2011 Gentle Bytes. All rights reserved.
7 //
8
9 #import "GBApplicationSettingsProvider.h"
10 #import "GBDataObjects.h"
11 #import "GBStore.h"
12 #import "GBCommentsProcessor.h"
13
14 @interface GBCommentsProcessor (PrivateAPI)
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
15 - (NSString *)stringByPreprocessingString:(NSString *)string withFlags:(NSUInteger)flags;
16 - (NSString *)stringByConvertingCrossReferencesInString:(NSString *)string withFlags:(NSUInteger)flags;
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
17 @end
18
19 #pragma mark -
20
21 @interface GBCommentsProcessorPreprocessingTesting : GBObjectsAssertor
12db6a0 @tomaz Implemented URL cross references processing.
authored
22
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
23 - (GBCommentsProcessor *)defaultProcessor;
fee2ccc @tomaz Implemented class, protocol and category links.
authored
24 - (GBCommentsProcessor *)processorWithStore:(id)store;
ed442bd @tomaz Implemented local methods and properties processing.
authored
25 - (GBCommentsProcessor *)processorWithStore:(id)store context:(id)context;
12db6a0 @tomaz Implemented URL cross references processing.
authored
26
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
27 @end
28
29 #pragma mark -
30
31 @implementation GBCommentsProcessorPreprocessingTesting
32
33 #pragma mark Formatting markers conversion
34
e81e2f8 @tomaz Fixed usage of single star as bold marker (kind of). Closes #154.
authored
35 - (void)testStringByPreprocessingString_shouldConvertAppledocBoldMarkersToTemporarySyntaxIfRequested {
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
36 // setup
e81e2f8 @tomaz Fixed usage of single star as bold marker (kind of). Closes #154.
authored
37 id settings = [GBTestObjectsRegistry realSettingsProvider];
38 [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
39 [settings setUseSingleStarForBold:YES];
40 GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:settings];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
41 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
42 NSString *result1 = [processor stringByPreprocessingString:@"*bold1* *bold text* * bolder text *" withFlags:0];
43 NSString *result2 = [processor stringByPreprocessingString:@"*bold1* Middle *bold text*" withFlags:0];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
44 // verify
1fad580 @tomaz Fixed remaining unit tests, now again to 0 faults...
authored
45 assertThat(result1, is(@"**~!$bold1$!~** **~!$bold text$!~** **~!$ bolder text $!~**"));
46 assertThat(result2, is(@"**~!$bold1$!~** Middle **~!$bold text$!~**"));
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
47 }
48
e81e2f8 @tomaz Fixed usage of single star as bold marker (kind of). Closes #154.
authored
49 - (void)testStringByPreprocessingString_shouldNotConvertAppledocBoldMarkersToTemporarySyntaxIfPrevented {
50 // setup
51 id settings = [GBTestObjectsRegistry realSettingsProvider];
52 [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
53 [settings setUseSingleStarForBold:NO];
54 GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:settings];
55 // execute
56 NSString *result1 = [processor stringByPreprocessingString:@"*bold1* *bold text* * bolder text *" withFlags:0];
57 NSString *result2 = [processor stringByPreprocessingString:@"*bold1* Middle *bold text*" withFlags:0];
58 // verify
59 assertThat(result1, is(@"*bold1* *bold text* * bolder text *"));
60 assertThat(result2, is(@"*bold1* Middle *bold text*"));
61 }
62
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
63 - (void)testStringByPreprocessingString_shouldLeaveItalicsMarkers {
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
64 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
65 GBCommentsProcessor *processor = [self defaultProcessor];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
66 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
67 NSString *result1 = [processor stringByPreprocessingString:@"_bold1_ _bold text_ _ bolder text _" withFlags:0];
68 NSString *result2 = [processor stringByPreprocessingString:@"_bold1_ Middle _bold text_" withFlags:0];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
69 // verify
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
70 assertThat(result1, is(@"_bold1_ _bold text_ _ bolder text _"));
71 assertThat(result2, is(@"_bold1_ Middle _bold text_"));
72 }
73
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
74 - (void)testStringByPreprocessingString_shouldLeaveBoldItalicsMarkers {
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
75 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
76 GBCommentsProcessor *processor = [self defaultProcessor];
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
77 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
78 NSString *result = [processor stringByPreprocessingString:@"_*text1*_ *_marked text_* _* text2 *_" withFlags:0];
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
79 // verify
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
80 assertThat(result, is(@"_*text1*_ *_marked text_* _* text2 *_"));
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
81 }
82
83 - (void)testStringByPreprocessingString_shouldHandleMonospaceMarkers {
84 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
85 GBCommentsProcessor *processor = [self defaultProcessor];
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
86 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
87 NSString *result = [processor stringByPreprocessingString:@"`mono` ` monoer `" withFlags:0];
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
88 // verify
89 assertThat(result, is(@"`mono` ` monoer `"));
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
90 }
91
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
92 - (void)testStringByPreprocessingString_shouldHandleMarkdownBoldMarkers {
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
93 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
94 GBCommentsProcessor *processor = [self defaultProcessor];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
95 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
96 NSString *result1 = [processor stringByPreprocessingString:@"__text1__ __ marked __" withFlags:0];
97 NSString *result2 = [processor stringByPreprocessingString:@"**text1** ** marked **" withFlags:0];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
98 // verify
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
99 assertThat(result1, is(@"__text1__ __ marked __"));
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
100 assertThat(result2, is(@"**text1** ** marked **"));
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
101 }
102
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
103 - (void)testStringByPreprocessingString_shouldLeaveMarkdownBoldItalicsMarkers {
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
104 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
105 GBCommentsProcessor *processor = [self defaultProcessor];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
106 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
107 NSString *result1 = [processor stringByPreprocessingString:@"__*text1*__ __* marked *__" withFlags:0];
108 NSString *result2 = [processor stringByPreprocessingString:@"_**text1**_ _** marked **_" withFlags:0];
109 NSString *result3 = [processor stringByPreprocessingString:@"*__text1__* *__ marked __*" withFlags:0];
110 NSString *result4 = [processor stringByPreprocessingString:@"**_text1_** **_ marked _**" withFlags:0];
111 NSString *result5 = [processor stringByPreprocessingString:@"___text1___ ___ marked ___" withFlags:0];
112 NSString *result6 = [processor stringByPreprocessingString:@"***text1*** *** marked ***" withFlags:0];
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
113 // verify
a85a42b @tomaz Fixed conversion of single to double star within example blocks and s…
authored
114 assertThat(result1, is(@"__*text1*__ __* marked *__"));
115 assertThat(result2, is(@"_**text1**_ _** marked **_"));
116 assertThat(result3, is(@"*__text1__* *__ marked __*"));
117 assertThat(result4, is(@"**_text1_** **_ marked _**"));
118 assertThat(result5, is(@"___text1___ ___ marked ___"));
b69ffde @tomaz Fixed Markdown style bold/italics markers processing and added more u…
authored
119 assertThat(result6, is(@"***text1*** *** marked ***"));
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
120 }
121
1760fc2 @robbertkl Fix handling of links containing underscores
robbertkl authored
122 - (void)testStringByPreprocessingString_shouldKeepReferencesWithMarkersIntact {
123 // setup
124 GBCommentsProcessor *processor = [self defaultProcessor];
125 // execute
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
126 NSString *result = [processor stringByPreprocessingString:@"[test_test](http://www.example.com/test_test.html)" withFlags:0];
127 NSString *result2 = [processor stringByPreprocessingString:@"![test_test](http://www.example.com/test_test.html)" withFlags:0];
1760fc2 @robbertkl Fix handling of links containing underscores
robbertkl authored
128 // verify
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
129 assertThat(result, is(@"[test_test](http://www.example.com/test_test.html)"));
130 assertThat(result2, is(@"![test_test](http://www.example.com/test_test.html)"));
1760fc2 @robbertkl Fix handling of links containing underscores
robbertkl authored
131 }
132
dfecc85 @jodyhagins Ignore source-code-blocks while processing comments.
jodyhagins authored
133 - (void)testStringByPreprocessingString_shouldConvertCodeBlockToMarkdownBackticks {
134 // setup
135 GBCommentsProcessor *processor = [self defaultProcessor];
136 // execute
137 NSString *result = [processor stringByPreprocessingString:@"\n @code \n[self doSomething];\n @endcode \n" withFlags:0];
138 // verify
139 assertThat(result, is(@"\n```\n[self doSomething];\n```\n"));
140 }
141
142 - (void)testStringByPreprocessingString_shouldConvertTildeCodeBlockToMarkdownBackticks {
143 // setup
144 GBCommentsProcessor *processor = [self defaultProcessor];
145 // execute
146 NSString *result = [processor stringByPreprocessingString:@"\n ~~~ \n[self doSomething];\n ~~~ \n" withFlags:0];
147 // verify
148 assertThat(result, is(@"\n```\n[self doSomething];\n```\n"));
149 }
150
151 - (void)testStringByPreprocessingString_shouldConvertBacktickCodeBlockToMarkdownBackticks {
152 // setup
153 GBCommentsProcessor *processor = [self defaultProcessor];
154 // execute
155 NSString *result = [processor stringByPreprocessingString:@"\n ``` \n[self doSomething];\n ``` \n" withFlags:0];
156 // verify
157 assertThat(result, is(@"\n```\n[self doSomething];\n```\n"));
158 }
159
3f3281f @jodyhagins Fix multiple code blocks in same comment block.
jodyhagins authored
160 - (void)testStringByPreprocessingString_shouldConvertMultipleCodeBlocksToMarkdownBackticks {
161 // setup
162 GBCommentsProcessor *processor = [self defaultProcessor];
163 NSString *raw = @"\n @code \n[self doSomething];\n @endcode \n\n @code \n[self doSomething];\n @endcode \n";
164 NSString *expected = @"\n```\n[self doSomething];\n```\n\n```\n[self doSomething];\n```\n";
165 // execute
166 NSString *result = [processor stringByPreprocessingString:raw withFlags:0];
167 // verify
168 assertThat(result, is(expected));
169 }
170
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
171 #pragma mark Class, category and protocol cross references detection
12db6a0 @tomaz Implemented URL cross references processing.
authored
172
fee2ccc @tomaz Implemented class, protocol and category links.
authored
173 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClass {
174 // setup
175 GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBClassData classDataWithName:@"Class"], nil];
176 GBCommentsProcessor *processor = [self processorWithStore:store];
177 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
178 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class" withFlags:0];
179 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Class>" withFlags:0];
180 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Unknown" withFlags:0];
181 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Unknown>" withFlags:0];
fee2ccc @tomaz Implemented class, protocol and category links.
authored
182 // verify
183 assertThat(result1, is(@"[Class](Classes/Class.html)"));
184 assertThat(result2, is(@"[Class](Classes/Class.html)"));
185 assertThat(result3, is(@"Unknown"));
186 assertThat(result4, is(@"<Unknown>"));
187 }
188
189 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategory {
190 // setup
191 GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBCategoryData categoryDataWithName:@"Category" className:@"Class"], nil];
192 GBCommentsProcessor *processor = [self processorWithStore:store];
193 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
194 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class(Category)" withFlags:0];
195 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Class(Category)>" withFlags:0];
196 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Class(Unknown)" withFlags:0];
197 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Class(Unknown)>" withFlags:0];
fee2ccc @tomaz Implemented class, protocol and category links.
authored
198 // verify
178a2ce @tomaz Fixed unit tests for handling paths to category files. References #160.
authored
199 assertThat(result1, is(@"[Class(Category)](Categories/Class+Category.html)"));
200 assertThat(result2, is(@"[Class(Category)](Categories/Class+Category.html)"));
fee2ccc @tomaz Implemented class, protocol and category links.
authored
201 assertThat(result3, is(@"Class(Unknown)"));
202 assertThat(result4, is(@"<Class(Unknown)>"));
203 }
204
205 - (void)testStringByConvertingCrossReferencesInString_shouldConvertProtocol {
206 // setup
207 GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBProtocolData protocolDataWithName:@"Protocol"], nil];
208 GBCommentsProcessor *processor = [self processorWithStore:store];
209 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
210 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Protocol" withFlags:0];
211 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Protocol>" withFlags:0];
212 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Unknown" withFlags:0];
213 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Unknown>" withFlags:0];
fee2ccc @tomaz Implemented class, protocol and category links.
authored
214 // verify
215 assertThat(result1, is(@"[Protocol](Protocols/Protocol.html)"));
216 assertThat(result2, is(@"[Protocol](Protocols/Protocol.html)"));
217 assertThat(result3, is(@"Unknown"));
218 assertThat(result4, is(@"<Unknown>"));
219 }
220
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
221 #pragma mark Local members cross references detection
222
ed442bd @tomaz Implemented local methods and properties processing.
authored
223 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalInstanceMethod {
224 // setup
225 GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
226 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
227 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
228 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
229 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
230 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
231 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-method:" withFlags:0];
232 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-method:>" withFlags:0];
233 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another:" withFlags:0];
234 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another:>" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
235 // verify
236 assertThat(result1, is(@"[method:](#//api/name/method:)"));
237 assertThat(result2, is(@"[method:](#//api/name/method:)"));
238 assertThat(result3, is(@"[method:](#//api/name/method:)"));
239 assertThat(result4, is(@"[method:](#//api/name/method:)"));
240 assertThat(result5, is(@"another:"));
241 assertThat(result6, is(@"<another:>"));
242 }
243
244 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalClassMethod {
245 // setup
246 GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry classMethodWithNames:@"method", nil], nil];
247 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
248 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
249 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
250 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
251 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
252 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"+method:" withFlags:0];
253 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<+method:>" withFlags:0];
254 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another:" withFlags:0];
255 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another:>" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
256 // verify
257 assertThat(result1, is(@"[method:](#//api/name/method:)"));
258 assertThat(result2, is(@"[method:](#//api/name/method:)"));
259 assertThat(result3, is(@"[method:](#//api/name/method:)"));
260 assertThat(result4, is(@"[method:](#//api/name/method:)"));
261 assertThat(result5, is(@"another:"));
262 assertThat(result6, is(@"<another:>"));
263 }
264
265 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalProperty {
266 // setup
267 GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry propertyMethodWithArgument:@"method"], nil];
268 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
269 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
270 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
271 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method" withFlags:0];
272 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method>" withFlags:0];
273 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
274 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
275 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another" withFlags:0];
276 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another>" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
277 // verify
278 assertThat(result1, is(@"[method](#//api/name/method)"));
279 assertThat(result2, is(@"[method](#//api/name/method)"));
280 assertThat(result3, is(@"method:"));
281 assertThat(result4, is(@"<method:>"));
282 assertThat(result5, is(@"another"));
283 assertThat(result6, is(@"<another>"));
284 }
285
286 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalInstanceMethod {
287 // setup
288 id method1 = [GBTestObjectsRegistry instanceMethodWithNames:@"method1", nil];
289 id method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"method2", nil];
290 GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
291 GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
292 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
293 GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
294 GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
295 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
296 NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
297 NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1:>" withFlags:0];
298 NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
299 NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
300 NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2:>" withFlags:0];
301 NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
302 // verify
303 assertThat(result1, is(@"[method1:](#//api/name/method1:)"));
304 assertThat(result2, is(@"[method1:](#//api/name/method1:)"));
305 assertThat(result3, is(@"method2:"));
306 assertThat(result4, is(@"[method2:](#//api/name/method2:)"));
307 assertThat(result5, is(@"[method2:](#//api/name/method2:)"));
308 assertThat(result6, is(@"method1:"));
309 }
310
311 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalClassMethod {
312 // setup
313 id method1 = [GBTestObjectsRegistry classMethodWithNames:@"method1", nil];
314 id method2 = [GBTestObjectsRegistry classMethodWithNames:@"method2", nil];
315 GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
316 GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
317 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
318 GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
319 GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
320 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
321 NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
322 NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1:>" withFlags:0];
323 NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
324 NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
325 NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2:>" withFlags:0];
326 NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
327 // verify
328 assertThat(result1, is(@"[method1:](#//api/name/method1:)"));
329 assertThat(result2, is(@"[method1:](#//api/name/method1:)"));
330 assertThat(result3, is(@"method2:"));
331 assertThat(result4, is(@"[method2:](#//api/name/method2:)"));
332 assertThat(result5, is(@"[method2:](#//api/name/method2:)"));
333 assertThat(result6, is(@"method1:"));
334 }
335
336 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalProperty {
337 // setup
338 id method1 = [GBTestObjectsRegistry propertyMethodWithArgument:@"method1"];
339 id method2 = [GBTestObjectsRegistry propertyMethodWithArgument:@"method2"];
340 GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
341 GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
342 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
343 GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
344 GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
345 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
346 NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1" withFlags:0];
347 NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1>" withFlags:0];
348 NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2" withFlags:0];
349 NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2" withFlags:0];
350 NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2>" withFlags:0];
351 NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1" withFlags:0];
ed442bd @tomaz Implemented local methods and properties processing.
authored
352 // verify
353 assertThat(result1, is(@"[method1](#//api/name/method1)"));
354 assertThat(result2, is(@"[method1](#//api/name/method1)"));
355 assertThat(result3, is(@"method2"));
356 assertThat(result4, is(@"[method2](#//api/name/method2)"));
357 assertThat(result5, is(@"[method2](#//api/name/method2)"));
358 assertThat(result6, is(@"method1"));
359 }
360
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
361 #pragma mark Remote members cross references detection
362
363 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassRemoteInstanceMethod {
364 // setup
365 GBClassData *class1 = [GBTestObjectsRegistry classWithName:@"Class1" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
366 GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
367 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class1, class2, nil];
368 GBCommentsProcessor *processor = [self processorWithStore:store context:class2];
369 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
370 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Class1 method:]" withFlags:0];
371 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Class1 method:]>" withFlags:0];
372 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Class1 method:]" withFlags:0];
373 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Class1 method:]>" withFlags:0];
374 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Unknown method:]" withFlags:0];
375 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
376 // verify
377 assertThat(result1, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
378 assertThat(result2, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
379 assertThat(result3, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
380 assertThat(result4, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
381 assertThat(result5, is(@"[Unknown method:]"));
382 assertThat(result6, is(@"method:"));
383 }
384
385 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryRemoteInstanceMethod {
386 // setup
387 GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
388 GBClassData *class = [GBClassData classDataWithName:@"Class"];
389 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, class, nil];
390 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
391 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
392 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Class(Category) method:]" withFlags:0];
393 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Class(Category) method:]>" withFlags:0];
394 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Class(Category) method:]" withFlags:0];
395 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Class(Category) method:]>" withFlags:0];
396 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Class(Unknown) method:]" withFlags:0];
397 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[Unknown(Category) method:]" withFlags:0];
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
398 // verify
178a2ce @tomaz Fixed unit tests for handling paths to category files. References #160.
authored
399 assertThat(result1, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
400 assertThat(result2, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
401 assertThat(result3, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
402 assertThat(result4, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
75c3211 @tomaz Updated remote member links preprocessing in case unknown object is f…
authored
403 assertThat(result5, is(@"[Class(Unknown) method:]"));
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
404 assertThat(result6, is(@"[Unknown(Category) method:]"));
405 }
406
407 - (void)testStringByConvertingCrossReferencesInString_shouldConvertProtocolRemoteInstanceMethod {
408 // setup
409 GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
410 GBClassData *class = [GBClassData classDataWithName:@"Class"];
411 GBStore *store = [GBTestObjectsRegistry storeWithObjects:protocol, class, nil];
412 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
413 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
414 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Protocol method:]" withFlags:0];
415 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Protocol method:]>" withFlags:0];
416 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Protocol method:]" withFlags:0];
417 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Protocol method:]>" withFlags:0];
418 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Unknown method:]" withFlags:0];
419 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
420 // verify
421 assertThat(result1, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
422 assertThat(result2, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
423 assertThat(result3, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
424 assertThat(result4, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
425 assertThat(result5, is(@"[Unknown method:]"));
426 assertThat(result6, is(@"method:"));
427 }
428
90e875d @tomaz Fixed remote member cross references handling when object is known bu…
authored
429 - (void)testStringByConvertingCrossReferencesInString_shouldKeepUnknownRemoteMemberEvenIfObjectIsKnown {
430 // setup
431 GBClassData *class1 = [GBTestObjectsRegistry classWithName:@"Class1" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
432 GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
433 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class1, class2, nil];
434 GBCommentsProcessor *processor = [self processorWithStore:store context:class2];
435 // execute
436 NSString *result = [processor stringByConvertingCrossReferencesInString:@"[Class1 unknown:]" withFlags:0];
437 // verify
438 assertThat(result, is(@"[Class1 unknown:]"));
439 }
440
4502f13 @tomaz Added document links processing.
authored
441 #pragma mark Document references detection
442
443 - (void)testStringByConvertingCrossReferencesInString_shouldConvertDocument {
444 // setup
445 GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"Document1.html"];
446 GBStore *store = [GBTestObjectsRegistry storeWithObjects:document, nil];
447 GBCommentsProcessor *processor = [self processorWithStore:store context:nil];
448 // execute
449 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Document1" withFlags:0];
450 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Document1>" withFlags:0];
451 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Document12" withFlags:0];
452 // verify
453 assertThat(result1, is(@"[Document1](docs/Document1.html)"));
454 assertThat(result2, is(@"[Document1](docs/Document1.html)"));
455 assertThat(result3, is(@"Document12"));
456 }
457
36b7a71 @tomaz Implemented remote members cross refs detection.
authored
458 #pragma mark URL cross references detection
459
12db6a0 @tomaz Implemented URL cross references processing.
authored
460 - (void)testStringByConvertingCrossReferencesInString_shouldConvertHTML {
461 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
462 GBCommentsProcessor *processor = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
463 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
464 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"http://gentlebytes.com" withFlags:0];
465 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"https://gentlebytes.com" withFlags:0];
466 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<http://gentlebytes.com>" withFlags:0];
467 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<https://gentlebytes.com>" withFlags:0];
468 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"http://gentlebytes.com https://gentlebytes.com" withFlags:0];
469 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"https://gentlebytes.com http://gentlebytes.com" withFlags:0];
12db6a0 @tomaz Implemented URL cross references processing.
authored
470 // verify
471 assertThat(result1, is(@"[http://gentlebytes.com](http://gentlebytes.com)"));
472 assertThat(result2, is(@"[https://gentlebytes.com](https://gentlebytes.com)"));
473 assertThat(result3, is(@"[http://gentlebytes.com](http://gentlebytes.com)"));
474 assertThat(result4, is(@"[https://gentlebytes.com](https://gentlebytes.com)"));
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
475 assertThat(result5, is(@"[http://gentlebytes.com](http://gentlebytes.com) [https://gentlebytes.com](https://gentlebytes.com)"));
476 assertThat(result6, is(@"[https://gentlebytes.com](https://gentlebytes.com) [http://gentlebytes.com](http://gentlebytes.com)"));
12db6a0 @tomaz Implemented URL cross references processing.
authored
477 }
478
479 - (void)testStringByConvertingCrossReferencesInString_shouldConvertFTP {
480 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
481 GBCommentsProcessor *processor = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
482 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
483 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"ftp://gentlebytes.com" withFlags:0];
484 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"ftps://gentlebytes.com" withFlags:0];
485 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<ftp://gentlebytes.com>" withFlags:0];
486 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<ftps://gentlebytes.com>" withFlags:0];
487 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"ftp://gentlebytes.com ftps://gentlebytes.com" withFlags:0];
488 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"ftps://gentlebytes.com ftp://gentlebytes.com" withFlags:0];
12db6a0 @tomaz Implemented URL cross references processing.
authored
489 // verify
490 assertThat(result1, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com)"));
491 assertThat(result2, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com)"));
492 assertThat(result3, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com)"));
493 assertThat(result4, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com)"));
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
494 assertThat(result5, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com) [ftps://gentlebytes.com](ftps://gentlebytes.com)"));
495 assertThat(result6, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com) [ftp://gentlebytes.com](ftp://gentlebytes.com)"));
12db6a0 @tomaz Implemented URL cross references processing.
authored
496 }
497
498 - (void)testStringByConvertingCrossReferencesInString_shouldConvertNewsAndRSS {
499 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
500 GBCommentsProcessor *processor = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
501 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
502 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"news://gentlebytes.com" withFlags:0];
503 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"rss://gentlebytes.com" withFlags:0];
504 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<news://gentlebytes.com>" withFlags:0];
505 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<rss://gentlebytes.com>" withFlags:0];
506 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"rss://gentlebytes.com news://gentlebytes.com" withFlags:0];
507 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"news://gentlebytes.com rss://gentlebytes.com" withFlags:0];
12db6a0 @tomaz Implemented URL cross references processing.
authored
508 // verify
509 assertThat(result1, is(@"[news://gentlebytes.com](news://gentlebytes.com)"));
510 assertThat(result2, is(@"[rss://gentlebytes.com](rss://gentlebytes.com)"));
511 assertThat(result3, is(@"[news://gentlebytes.com](news://gentlebytes.com)"));
512 assertThat(result4, is(@"[rss://gentlebytes.com](rss://gentlebytes.com)"));
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
513 assertThat(result5, is(@"[rss://gentlebytes.com](rss://gentlebytes.com) [news://gentlebytes.com](news://gentlebytes.com)"));
514 assertThat(result6, is(@"[news://gentlebytes.com](news://gentlebytes.com) [rss://gentlebytes.com](rss://gentlebytes.com)"));
12db6a0 @tomaz Implemented URL cross references processing.
authored
515 }
516
517 - (void)testStringByConvertingCrossReferencesInString_shouldConvertFile {
518 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
519 GBCommentsProcessor *processor = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
520 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
521 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"file://gentlebytes.com" withFlags:0];
522 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<file://gentlebytes.com>" withFlags:0];
523 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"file://first file://second" withFlags:0];
12db6a0 @tomaz Implemented URL cross references processing.
authored
524 // verify
525 assertThat(result1, is(@"[file://gentlebytes.com](file://gentlebytes.com)"));
526 assertThat(result2, is(@"[file://gentlebytes.com](file://gentlebytes.com)"));
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
527 assertThat(result3, is(@"[file://first](file://first) [file://second](file://second)"));
12db6a0 @tomaz Implemented URL cross references processing.
authored
528 }
529
530 - (void)testStringByConvertingCrossReferencesInString_shouldConvertMailto {
531 // setup
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
532 GBCommentsProcessor *processor = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
533 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
534 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"mailto:appledoc@gentlebytes.com" withFlags:0];
535 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<mailto:appledoc@gentlebytes.com>" withFlags:0];
536 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"mailto:a@b.com mailto:c@d.com" withFlags:0];
12db6a0 @tomaz Implemented URL cross references processing.
authored
537 // verify
538 assertThat(result1, is(@"[appledoc@gentlebytes.com](mailto:appledoc@gentlebytes.com)"));
539 assertThat(result2, is(@"[appledoc@gentlebytes.com](mailto:appledoc@gentlebytes.com)"));
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
540 assertThat(result3, is(@"[a@b.com](mailto:a@b.com) [c@d.com](mailto:c@d.com)"));
12db6a0 @tomaz Implemented URL cross references processing.
authored
541 }
542
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
543 #pragma mark Combinations detection testing
544
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
545 - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassAndProtocol {
546 // setup
547 GBClassData *class = [GBClassData classDataWithName:@"Class"];
548 GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
549 GBStore *store = [GBTestObjectsRegistry storeWithObjects:protocol, class, nil];
550 GBCommentsProcessor *processor = [self processorWithStore:store];
551 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
552 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class Protocol" withFlags:0];
553 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Protocol Class" withFlags:0];
20dbb3d @tomaz Added unit tests for verifying all cross refs are detected.
authored
554 // verify
555 assertThat(result1, is(@"[Class](Classes/Class.html) [Protocol](Protocols/Protocol.html)"));
556 assertThat(result2, is(@"[Protocol](Protocols/Protocol.html) [Class](Classes/Class.html)"));
557 }
558
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
559 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndClass {
560 // setup
561 GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
562 GBClassData *class = [GBClassData classDataWithName:@"Class"];
563 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, class, nil];
564 GBCommentsProcessor *processor = [self processorWithStore:store];
565 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
566 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class(Category) Class" withFlags:0];
567 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Class Class(Category)" withFlags:0];
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
568 // verify
178a2ce @tomaz Fixed unit tests for handling paths to category files. References #160.
authored
569 assertThat(result1, is(@"[Class(Category)](Categories/Class+Category.html) [Class](Classes/Class.html)"));
570 assertThat(result2, is(@"[Class](Classes/Class.html) [Class(Category)](Categories/Class+Category.html)"));
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
571 }
572
573 - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocol {
574 // setup - although it's not possible to do categories on protocols, we still test to properly cover these...
575 GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Protocol"];
576 GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
577 GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
578 GBCommentsProcessor *processor = [self processorWithStore:store];
579 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
580 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Protocol(Category) Protocol" withFlags:0];
581 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Protocol Protocol(Category)" withFlags:0];
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
582 // verify
178a2ce @tomaz Fixed unit tests for handling paths to category files. References #160.
authored
583 assertThat(result1, is(@"[Protocol(Category)](Categories/Protocol+Category.html) [Protocol](Protocols/Protocol.html)"));
584 assertThat(result2, is(@"[Protocol](Protocols/Protocol.html) [Protocol(Category)](Categories/Protocol+Category.html)"));
c738bb0 @tomaz Fixed categories links detection when a class with same name exists.
authored
585 }
586
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
587 #pragma mark Manual links detection testing
588
589 - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualLinks {
590 // setup
591 GBCommentsProcessor *processor = [self processorWithStore:nil];
592 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
593 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](something)" withFlags:0];
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
594 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[multi word](more words)" withFlags:0];
595 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"![multi word](more words)" withFlags:0];
596 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[![multi word](more words)](foo)" withFlags:0];
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
597 // verify
598 assertThat(result1, is(@"[text](something)"));
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
599 assertThat(result2, is(@"[multi word](more words)"));
600 assertThat(result3, is(@"![multi word](more words)"));
601 assertThat(result4, is(@"[![multi word](more words)](foo)"));
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
602 }
603
604 - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualURLLinks {
605 // setup
606 GBCommentsProcessor *processor = [self processorWithStore:nil];
607 // execute
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
608 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](http://ab.com)" withFlags:0];
609 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text](https://ab.com)" withFlags:0];
610 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](ftp://ab.com)" withFlags:0];
611 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text](ftps://ab.com)" withFlags:0];
612 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[text](news://ab.com)" withFlags:0];
613 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[text](rss://ab.com)" withFlags:0];
614 NSString *result7 = [processor stringByConvertingCrossReferencesInString:@"[text](mailto:a@b.com)" withFlags:0];
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
615 NSString *result8 = [processor stringByConvertingCrossReferencesInString:@"![text](http://ab.com)" withFlags:0];
616 NSString *result9 = [processor stringByConvertingCrossReferencesInString:@"[![text](https://ab.com)](https://zx.com)" withFlags:0];
617
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
618 // verify
619 assertThat(result1, is(@"[text](http://ab.com)"));
620 assertThat(result2, is(@"[text](https://ab.com)"));
621 assertThat(result3, is(@"[text](ftp://ab.com)"));
622 assertThat(result4, is(@"[text](ftps://ab.com)"));
623 assertThat(result5, is(@"[text](news://ab.com)"));
624 assertThat(result6, is(@"[text](rss://ab.com)"));
c5f0f83 @jodyhagins This fix addresses three related issues.
jodyhagins authored
625 assertThat(result7, is(@"[text](mailto:a@b.com)"));
626 assertThat(result8, is(@"![text](http://ab.com)"));
627 assertThat(result9, is(@"[![text](https://ab.com)](https://zx.com)"));
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
628 }
629
630 - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualObjectLinksAndUpdateAddress {
631 // setup
632 GBClassData *class = [GBClassData classDataWithName:@"Class"];
633 GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
634 GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
b863aab @tomaz Updated unit tests to cover more documents handling.
authored
635 GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"document.ext"];
636 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, category, protocol, document, nil];
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
637 GBCommentsProcessor *processor = [self processorWithStore:store];
638 // setup
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
639 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](Class)" withFlags:0];
640 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text](Class(Category))" withFlags:0];
641 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](Protocol)" withFlags:0];
b863aab @tomaz Updated unit tests to cover more documents handling.
authored
642 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text](document)" withFlags:0];
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
643 // verify
644 assertThat(result1, is(@"[text](Classes/Class.html)"));
178a2ce @tomaz Fixed unit tests for handling paths to category files. References #160.
authored
645 assertThat(result2, is(@"[text](Categories/Class+Category.html)"));
144d355 @tomaz Implemented proper Markdown links handling.
authored
646 assertThat(result3, is(@"[text](Protocols/Protocol.html)"));
b863aab @tomaz Updated unit tests to cover more documents handling.
authored
647 assertThat(result4, is(@"[text](docs/document.html)"));
e9a9d63 @tomaz Implemented grounds for preprocessing of Markdown syntax links.
authored
648 }
649
15817ad @kenji21 Tests and implementation for links with references to [Class method] …
kenji21 authored
650 - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualObjectMethodLinksAndUpdateAddress {
651 GBClassData *class = [GBClassData classDataWithName:@"Class"];
652 GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
653 GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
654 GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"document.ext"];
655
656 GBMethodArgument *argument = [GBMethodArgument methodArgumentWithName:@"method"];
657 GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithArguments:argument, nil];
658 GBMethodData *method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"doSomething", @"withVars", nil];
659 GBMethodData *property = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
660 [class.methods registerMethod:method1];
661 [class.methods registerMethod:method2];
662 [class.methods registerMethod:property];
663
664 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, category, protocol, document, nil];
665 GBCommentsProcessor *processor = [self processorWithStore:store];
666
667 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](+[Class method])" withFlags:0];
668 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text]([Class doSomething:withVars:])" withFlags:0];
669 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](-[Class value])" withFlags:0];
beee592 @kenji21 Fixing title with space not managed. Refs #237
kenji21 authored
670 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text with space](+[Class method])" withFlags:0];
c8b2b2e @kenji21 Fixing links with custom title detection (custom titles like [this me…
kenji21 authored
671 NSString *result4b = [processor stringByConvertingCrossReferencesInString:@"[text onlyOneSpace]([Class method])" withFlags:0];
672 NSString *result4c = [processor stringByConvertingCrossReferencesInString:@"[text](+[Class method]), [text onlyOneSpace]([Class method])" withFlags:0];
d0800f9 @kenji21 Fixing using specials chars in custom title. Refs #237
kenji21 authored
673 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:])" withFlags:0];
c8b2b2e @kenji21 Fixing links with custom title detection (custom titles like [this me…
kenji21 authored
674 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text]([Class method])" withFlags:0];
675 NSString *result7 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text with space]([Class method])" withFlags:0];
676 NSString *result8 = [processor stringByConvertingCrossReferencesInString:@"[text](<-[Class value]>)" withFlags:0];
677
15817ad @kenji21 Tests and implementation for links with references to [Class method] …
kenji21 authored
678 assertThat(result1, is(@"[text](Classes/Class.html#//api/name/method)"));
679 assertThat(result2, is(@"[text](Classes/Class.html#//api/name/doSomething:withVars:)"));
680 assertThat(result3, is(@"[text](Classes/Class.html#//api/name/value)"));
beee592 @kenji21 Fixing title with space not managed. Refs #237
kenji21 authored
681 assertThat(result4, is(@"[text with space](Classes/Class.html#//api/name/method)"));
c8b2b2e @kenji21 Fixing links with custom title detection (custom titles like [this me…
kenji21 authored
682 assertThat(result4b, is(@"[text onlyOneSpace](Classes/Class.html#//api/name/method)"));
683 assertThat(result4c, is(@"[text](Classes/Class.html#//api/name/method), [text onlyOneSpace](Classes/Class.html#//api/name/method)"));
d0800f9 @kenji21 Fixing using specials chars in custom title. Refs #237
kenji21 authored
684 assertThat(result5, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:)"));
c8b2b2e @kenji21 Fixing links with custom title detection (custom titles like [this me…
kenji21 authored
685 assertThat(result6, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text](Classes/Class.html#//api/name/method)"));
686 assertThat(result7, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text with space](Classes/Class.html#//api/name/method)"));
687 assertThat(result8, is(@"[text](Classes/Class.html#//api/name/value)"));
15817ad @kenji21 Tests and implementation for links with references to [Class method] …
kenji21 authored
688 }
689
50cfa17 @tomaz Added more unit tests for validating manual Markdown links handling.
authored
690 - (void)testStringByConvertingCrossReferencesInString_shouldIgnoreKnownObjectsInManualLinkDescriptionOrTitle {
691 // setup
692 GBClassData *class = [GBClassData classDataWithName:@"Class"];
693 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
694 GBCommentsProcessor *processor = [self processorWithStore:store];
695 // setup
b863aab @tomaz Updated unit tests to cover more documents handling.
authored
696 NSString *result = [processor stringByConvertingCrossReferencesInString:@"[Class](Class \"Class\")" withFlags:0];
50cfa17 @tomaz Added more unit tests for validating manual Markdown links handling.
authored
697 // verify
b863aab @tomaz Updated unit tests to cover more documents handling.
authored
698 assertThat(result, is(@"[Class](Classes/Class.html \"Class\")"));
50cfa17 @tomaz Added more unit tests for validating manual Markdown links handling.
authored
699 }
700
f531b9d @tomaz Another short unit test for validating proper handling of Markdown re…
authored
701 - (void)testStringByConvertingCrossReferencesInString_shouldHandleMarkdownLinkReferences {
702 // setup
703 GBClassData *class = [GBClassData classDataWithName:@"Class"];
704 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
705 GBCommentsProcessor *processor = [self processorWithStore:store];
706 // setup
8a21c3a @tomaz Refactored internal handling of comments processing methods to accept…
authored
707 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[1]: http://ab.com" withFlags:0];
708 NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[1]: http://ab.com \"title\"" withFlags:0];
709 NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[1]: Class" withFlags:0];
710 NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[1]: Class \"title\"" withFlags:0];
711 NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Class]: something" withFlags:0];
712 NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[1]: something \"Class\"" withFlags:0];
f531b9d @tomaz Another short unit test for validating proper handling of Markdown re…
authored
713 // verify
714 assertThat(result1, is(@"[1]: http://ab.com"));
715 assertThat(result2, is(@"[1]: http://ab.com \"title\""));
716 assertThat(result3, is(@"[1]: Classes/Class.html"));
717 assertThat(result4, is(@"[1]: Classes/Class.html \"title\""));
718 assertThat(result5, is(@"[Class]: something"));
719 assertThat(result6, is(@"[1]: something \"Class\""));
720 }
721
3485e41 @paulmelnikow Fix link content duplication when links are embedded inside other links
paulmelnikow authored
722 #pragma mark Links inside of links testing
723
724 - (void) testStringByConvertingCrossReferencesInString_shouldIgnoreLinksInsideOtherLinks {
725 // setup
726 GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry classMethodWithNames:@"URLWithString", nil], nil];
727 GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
728 GBCommentsProcessor *processor = [self processorWithStore:store context:class];
729 // execute
730 NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Class URLWithString:@\"http://gentlebytes.com\"]" withFlags:0];
731 // verify
732 assertThat(result1, is(@"[Class URLWithString:@\"http://gentlebytes.com\"]"));
733 }
734
735
12db6a0 @tomaz Implemented URL cross references processing.
authored
736 #pragma mark Creation methods
737
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
738 - (GBCommentsProcessor *)defaultProcessor {
739 // Creates a new GBCommentsProcessor using real settings. Note that we disable embedding cross references to make test strings more readable.
740 id settings = [GBTestObjectsRegistry realSettingsProvider];
741 [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
742 return [GBCommentsProcessor processorWithSettingsProvider:settings];
743 }
744
fee2ccc @tomaz Implemented class, protocol and category links.
authored
745 - (GBCommentsProcessor *)processorWithStore:(id)store {
746 // Creates a new GBCommentsProcessor using real settings and the given store.
ed442bd @tomaz Implemented local methods and properties processing.
authored
747 return [self processorWithStore:store context:nil];
748 }
749
750 - (GBCommentsProcessor *)processorWithStore:(id)store context:(id)context {
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
751 // Creates a new GBCommentsProcessor using real settings and the given store and context. Note that we disable embedding cross references to make test strings more readable.
12db6a0 @tomaz Implemented URL cross references processing.
authored
752 id settings = [GBTestObjectsRegistry realSettingsProvider];
604dffb @tomaz Fixed code blocks auto generated links handling.
authored
753 [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
754 GBCommentsProcessor *result = [self defaultProcessor];
12db6a0 @tomaz Implemented URL cross references processing.
authored
755 [result setValue:store forKey:@"store"];
ed442bd @tomaz Implemented local methods and properties processing.
authored
756 [result setValue:context forKey:@"currentContext"];
12db6a0 @tomaz Implemented URL cross references processing.
authored
757 return result;
758 }
759
9fa9fd9 @tomaz Implemented basic formatting markers conversion to Markdown style.
authored
760 @end
Something went wrong with that request. Please try again.