1 | Unit FileUtilsUnitTests;
|
---|
2 |
|
---|
3 | // NewView - a new OS/2 Help Viewer
|
---|
4 | // Copyright 2006-2007 Ronald Brill (rbri at rbri dot de)
|
---|
5 | // This software is released under the GNU Public License - see readme.txt
|
---|
6 |
|
---|
7 | // UnitTests for FileUtilsUnit
|
---|
8 |
|
---|
9 | Interface
|
---|
10 |
|
---|
11 | uses
|
---|
12 | Classes,
|
---|
13 | TestAssert,
|
---|
14 | FileUtilsUnit;
|
---|
15 |
|
---|
16 | const
|
---|
17 | // TODO read environment var
|
---|
18 | TEST_PATH = 'P:\newview_dev';
|
---|
19 |
|
---|
20 | FUNCTION getFileUtilsUnitTests : TList;
|
---|
21 |
|
---|
22 |
|
---|
23 | Implementation
|
---|
24 |
|
---|
25 | Procedure testAddDirectorySeparator_Empty;
|
---|
26 | var
|
---|
27 | tmpResult : String;
|
---|
28 | begin
|
---|
29 | tmpResult := AddDirectorySeparator('');
|
---|
30 |
|
---|
31 | assertEqualsString('testAddDirectorySeparator_Empty', '\', tmpResult);
|
---|
32 | end;
|
---|
33 |
|
---|
34 | Procedure testAddDirectorySeparator_SingleChar;
|
---|
35 | var
|
---|
36 | tmpResult : String;
|
---|
37 | begin
|
---|
38 | tmpResult := AddDirectorySeparator('x');
|
---|
39 |
|
---|
40 | assertEqualsString('testAddDirectorySeparator_SingleChar', 'x\', tmpResult);
|
---|
41 | end;
|
---|
42 |
|
---|
43 | Procedure testAddDirectorySeparator_ManyChars;
|
---|
44 | var
|
---|
45 | tmpResult : String;
|
---|
46 | begin
|
---|
47 | tmpResult := AddDirectorySeparator('xyz dkdj ');
|
---|
48 |
|
---|
49 | assertEqualsString('testAddDirectorySeparator_ManyChars', 'xyz dkdj \', tmpResult);
|
---|
50 | end;
|
---|
51 |
|
---|
52 |
|
---|
53 | Procedure testAddDirectorySeparator_SlashAtEnd;
|
---|
54 | var
|
---|
55 | tmpResult : String;
|
---|
56 | begin
|
---|
57 | tmpResult := AddDirectorySeparator('xy\');
|
---|
58 |
|
---|
59 | assertEqualsString('testAddDirectorySeparator_SlashAtEnd', 'xy\', tmpResult);
|
---|
60 | end;
|
---|
61 |
|
---|
62 |
|
---|
63 | // ----------------------------------------------------------
|
---|
64 |
|
---|
65 |
|
---|
66 | Procedure testAddDirectorySeparatorIfNotEmpty_Empty;
|
---|
67 | var
|
---|
68 | tmpResult : String;
|
---|
69 | begin
|
---|
70 | tmpResult := AddDirectorySeparatorIfNotEmpty('');
|
---|
71 |
|
---|
72 | assertEqualsString('testAddDirectorySeparatorIfNotEmpty_Empty', '', tmpResult);
|
---|
73 | end;
|
---|
74 |
|
---|
75 | Procedure testAddDirectorySeparatorIfNotEmpty_SingleChar;
|
---|
76 | var
|
---|
77 | tmpResult : String;
|
---|
78 | begin
|
---|
79 | tmpResult := AddDirectorySeparatorIfNotEmpty('x');
|
---|
80 |
|
---|
81 | assertEqualsString('testAddDirectorySeparatorIfNotEmpty_SingleChar', 'x\', tmpResult);
|
---|
82 | end;
|
---|
83 |
|
---|
84 | Procedure testAddDirectorySeparatorIfNotEmpty_ManyChars;
|
---|
85 | var
|
---|
86 | tmpResult : String;
|
---|
87 | begin
|
---|
88 | tmpResult := AddDirectorySeparatorIfNotEmpty('xyz dkdj ');
|
---|
89 |
|
---|
90 | assertEqualsString('testAddDirectorySeparatorIfNotEmpty_ManyChars', 'xyz dkdj \', tmpResult);
|
---|
91 | end;
|
---|
92 |
|
---|
93 |
|
---|
94 | Procedure testAddDirectorySeparatorIfNotEmpty_SlashAtEnd;
|
---|
95 | var
|
---|
96 | tmpResult : String;
|
---|
97 | begin
|
---|
98 | tmpResult := AddDirectorySeparatorIfNotEmpty('xy\');
|
---|
99 |
|
---|
100 | assertEqualsString('testAddDirectorySeparatorIfNotEmpty_SlashAtEnd', 'xy\', tmpResult);
|
---|
101 | end;
|
---|
102 |
|
---|
103 |
|
---|
104 | // ----------------------------------------------------------
|
---|
105 |
|
---|
106 |
|
---|
107 | Procedure testRemoveRightDirectorySeparator_Empty;
|
---|
108 | var
|
---|
109 | tmpResult : String;
|
---|
110 | begin
|
---|
111 | tmpResult := RemoveRightDirectorySeparator('');
|
---|
112 |
|
---|
113 | assertEqualsString('testRemoveRightDirectorySeparator_Empty', '', tmpResult);
|
---|
114 | end;
|
---|
115 |
|
---|
116 |
|
---|
117 | Procedure testRemoveRightDirectorySeparator_WithoutSlash;
|
---|
118 | var
|
---|
119 | tmpResult : String;
|
---|
120 | begin
|
---|
121 | tmpResult := RemoveRightDirectorySeparator('abc');
|
---|
122 |
|
---|
123 | assertEqualsString('testRemoveRightDirectorySeparator_WithoutSlash', 'abc', tmpResult);
|
---|
124 | end;
|
---|
125 |
|
---|
126 |
|
---|
127 | Procedure testRemoveRightDirectorySeparator_WithSlash;
|
---|
128 | var
|
---|
129 | tmpResult : String;
|
---|
130 | begin
|
---|
131 | tmpResult := RemoveRightDirectorySeparator('abc\');
|
---|
132 |
|
---|
133 | assertEqualsString('testRemoveRightDirectorySeparator_WithSlash', 'abc', tmpResult);
|
---|
134 | end;
|
---|
135 |
|
---|
136 |
|
---|
137 | // ----------------------------------------------------------
|
---|
138 |
|
---|
139 | Procedure testExpandPath_BothEmpty;
|
---|
140 | var
|
---|
141 | tmpResult : String;
|
---|
142 | begin
|
---|
143 | tmpResult := ExpandPath('', '');
|
---|
144 |
|
---|
145 | assertEqualsString('testExpandPath_BothEmpty', '', tmpResult);
|
---|
146 | end;
|
---|
147 |
|
---|
148 |
|
---|
149 | Procedure testExpandPath_PathEmpty;
|
---|
150 | var
|
---|
151 | tmpResult : String;
|
---|
152 | begin
|
---|
153 | tmpResult := ExpandPath('\abc\def', '');
|
---|
154 |
|
---|
155 | assertEqualsString('testExpandPath_PathEmpty', '\abc\def', tmpResult);
|
---|
156 | end;
|
---|
157 |
|
---|
158 |
|
---|
159 | Procedure testExpandPath_PathEmptyDirEndsWithSlash;
|
---|
160 | var
|
---|
161 | tmpResult : String;
|
---|
162 | begin
|
---|
163 | tmpResult := ExpandPath('\abc\def\', '');
|
---|
164 |
|
---|
165 | assertEqualsString('testExpandPath_PathEmpty', '\abc\def', tmpResult);
|
---|
166 | end;
|
---|
167 |
|
---|
168 |
|
---|
169 | Procedure testExpandPath_AbsolutePath;
|
---|
170 | var
|
---|
171 | tmpResult : String;
|
---|
172 | begin
|
---|
173 | tmpResult := ExpandPath('\abc\def', 'c:\test');
|
---|
174 |
|
---|
175 | assertEqualsString('testExpandPath_AbsolutePath', 'c:\test', tmpResult);
|
---|
176 | end;
|
---|
177 |
|
---|
178 |
|
---|
179 | Procedure testExpandPath_DriveWithSlash;
|
---|
180 | var
|
---|
181 | tmpResult : String;
|
---|
182 | begin
|
---|
183 | tmpResult := ExpandPath('\abc\def', 'c:\');
|
---|
184 |
|
---|
185 | assertEqualsString('testExpandPath_DriveWithSlash', 'c:\', tmpResult);
|
---|
186 | end;
|
---|
187 |
|
---|
188 |
|
---|
189 | Procedure testExpandPath_DriveWithoutSlash;
|
---|
190 | var
|
---|
191 | tmpResult : String;
|
---|
192 | begin
|
---|
193 | tmpResult := ExpandPath('\abc\def', 'c:');
|
---|
194 |
|
---|
195 | assertEqualsString('testExpandPath_DriveWithoutSlash', 'c:\', tmpResult);
|
---|
196 | end;
|
---|
197 |
|
---|
198 |
|
---|
199 | Procedure testExpandPath_RootPathForDrive;
|
---|
200 | var
|
---|
201 | tmpResult : String;
|
---|
202 | begin
|
---|
203 | tmpResult := ExpandPath('d:\abc\def', '\');
|
---|
204 |
|
---|
205 | assertEqualsString('testExpandPath_RootPathForDrive', 'd:\', tmpResult);
|
---|
206 | end;
|
---|
207 |
|
---|
208 |
|
---|
209 | Procedure testExpandPath_RootDirForDrive;
|
---|
210 | var
|
---|
211 | tmpResult : String;
|
---|
212 | begin
|
---|
213 | tmpResult := ExpandPath('d:\abc\def', '\xy');
|
---|
214 |
|
---|
215 | assertEqualsString('testExpandPath_RootDirForDrive', 'd:\xy', tmpResult);
|
---|
216 | end;
|
---|
217 |
|
---|
218 |
|
---|
219 | Procedure testExpandPath_RootPathWithoutDrive;
|
---|
220 | var
|
---|
221 | tmpResult : String;
|
---|
222 | begin
|
---|
223 | tmpResult := ExpandPath('abc\def', '\');
|
---|
224 |
|
---|
225 | assertEqualsString('testExpandPath_RootPathWithoutDrive', '\', tmpResult);
|
---|
226 | end;
|
---|
227 |
|
---|
228 |
|
---|
229 | Procedure testExpandPath_RootDirWithoutDrive;
|
---|
230 | var
|
---|
231 | tmpResult : String;
|
---|
232 | begin
|
---|
233 | tmpResult := ExpandPath('abc\def', '\xyz');
|
---|
234 |
|
---|
235 | assertEqualsString('testExpandPath_RootDirWithoutDrive', '\xyz', tmpResult);
|
---|
236 | end;
|
---|
237 |
|
---|
238 |
|
---|
239 | Procedure testExpandPath_AppendWithSlash;
|
---|
240 | var
|
---|
241 | tmpResult : String;
|
---|
242 | begin
|
---|
243 | tmpResult := ExpandPath('abc\def\', 'xyz');
|
---|
244 |
|
---|
245 | assertEqualsString('testExpandPath_AppendWithSlash', 'abc\def\xyz', tmpResult);
|
---|
246 | end;
|
---|
247 |
|
---|
248 |
|
---|
249 | Procedure testExpandPath_AppendWithoutSlash;
|
---|
250 | var
|
---|
251 | tmpResult : String;
|
---|
252 | begin
|
---|
253 | tmpResult := ExpandPath('abc\def', 'xyz');
|
---|
254 |
|
---|
255 | assertEqualsString('testExpandPath_AppendWithoutSlash', 'abc\def\xyz', tmpResult);
|
---|
256 | end;
|
---|
257 |
|
---|
258 |
|
---|
259 | Procedure testExpandPath_AppendWithSlashAtEnd;
|
---|
260 | var
|
---|
261 | tmpResult : String;
|
---|
262 | begin
|
---|
263 | tmpResult := ExpandPath('abc\def', 'xyz\');
|
---|
264 |
|
---|
265 | assertEqualsString('testExpandPath_AppendWithSlashAtEnd', 'abc\def\xyz', tmpResult);
|
---|
266 | end;
|
---|
267 |
|
---|
268 |
|
---|
269 | Procedure testExpandPath_WithDot;
|
---|
270 | var
|
---|
271 | tmpResult : String;
|
---|
272 | begin
|
---|
273 | tmpResult := ExpandPath('abc\def', 'xyz\.\abc');
|
---|
274 |
|
---|
275 | assertEqualsString('testExpandPath_WithDot', 'abc\def\xyz\abc', tmpResult);
|
---|
276 | end;
|
---|
277 |
|
---|
278 |
|
---|
279 | Procedure testExpandPath_WithDotAtEnd;
|
---|
280 | var
|
---|
281 | tmpResult : String;
|
---|
282 | begin
|
---|
283 | tmpResult := ExpandPath('abc\def', 'xyz\.');
|
---|
284 |
|
---|
285 | assertEqualsString('testExpandPath_WithDotAtEnd', 'abc\def\xyz', tmpResult);
|
---|
286 | end;
|
---|
287 |
|
---|
288 |
|
---|
289 | Procedure testExpandPath_WithDots;
|
---|
290 | var
|
---|
291 | tmpResult : String;
|
---|
292 | begin
|
---|
293 | tmpResult := ExpandPath('abc\def', 'xyz\..\abc');
|
---|
294 |
|
---|
295 | assertEqualsString('testExpandPath_WithDots', 'abc\def\abc', tmpResult);
|
---|
296 | end;
|
---|
297 |
|
---|
298 |
|
---|
299 | Procedure testExpandPath_WithDotsAtEnd;
|
---|
300 | var
|
---|
301 | tmpResult : String;
|
---|
302 | begin
|
---|
303 | tmpResult := ExpandPath('abc\def', 'xyz\..');
|
---|
304 |
|
---|
305 | assertEqualsString('testExpandPath_WithDotsAtEnd', 'abc\def', tmpResult);
|
---|
306 | end;
|
---|
307 |
|
---|
308 |
|
---|
309 | Procedure testExpandPath_WithDotsInFront;
|
---|
310 | var
|
---|
311 | tmpResult : String;
|
---|
312 | begin
|
---|
313 | tmpResult := ExpandPath('abc\def', '..\xyz');
|
---|
314 |
|
---|
315 | assertEqualsString('testExpandPath_WithDotsInFront', 'abc\xyz', tmpResult);
|
---|
316 | end;
|
---|
317 |
|
---|
318 |
|
---|
319 | Procedure testExpandPath_WithDotsInFrontReachingRoot;
|
---|
320 | var
|
---|
321 | tmpResult : String;
|
---|
322 | begin
|
---|
323 | tmpResult := ExpandPath('abc\def', '..\..\xyz');
|
---|
324 |
|
---|
325 | assertEqualsString('testExpandPath_WithDotsInFrontReachingRoot', '\xyz', tmpResult);
|
---|
326 | end;
|
---|
327 |
|
---|
328 |
|
---|
329 | Procedure testExpandPath_WithDotsInFrontReachingDrive;
|
---|
330 | var
|
---|
331 | tmpResult : String;
|
---|
332 | begin
|
---|
333 | tmpResult := ExpandPath('c:\abc\def', '..\..\xyz');
|
---|
334 |
|
---|
335 | assertEqualsString('testExpandPath_WithDotsInFront', 'c:\xyz', tmpResult);
|
---|
336 | end;
|
---|
337 |
|
---|
338 |
|
---|
339 | Procedure testExpandPath_WithDotsInFrontLeavingRoot;
|
---|
340 | var
|
---|
341 | tmpResult : String;
|
---|
342 | begin
|
---|
343 | tmpResult := ExpandPath('abc\def', '..\..\..\xyz');
|
---|
344 |
|
---|
345 | assertEqualsString('testExpandPath_WithDotsInFrontLeavingRoot', '\xyz', tmpResult);
|
---|
346 | end;
|
---|
347 |
|
---|
348 |
|
---|
349 | Procedure testExpandPath_WithDotsInFrontLeavingDrive;
|
---|
350 | var
|
---|
351 | tmpResult : String;
|
---|
352 | begin
|
---|
353 | tmpResult := ExpandPath('c:\abc\def', '..\..\..\xyz');
|
---|
354 |
|
---|
355 | assertEqualsString('testExpandPath_WithDotsInFrontLeavingDrive', 'c:\xyz', tmpResult);
|
---|
356 | end;
|
---|
357 |
|
---|
358 |
|
---|
359 | // ----------------------------------------------------------
|
---|
360 |
|
---|
361 |
|
---|
362 | Procedure testGetLogFilesDir;
|
---|
363 | var
|
---|
364 | tmpResult : String;
|
---|
365 | begin
|
---|
366 | tmpResult := GetLogFilesDir;
|
---|
367 |
|
---|
368 | assertEqualsString('testGetLogFilesDir', 'C:\var\log\', tmpResult);
|
---|
369 | end;
|
---|
370 |
|
---|
371 |
|
---|
372 | // ----------------------------------------------------------
|
---|
373 |
|
---|
374 | Procedure testSearchPath_Found;
|
---|
375 | var
|
---|
376 | tmpResult : Boolean;
|
---|
377 | tmpResultFilename : String;
|
---|
378 | begin
|
---|
379 | tmpResult := SearchPath('BOOKSHELF', 'CMDREF.INF', tmpResultFilename);
|
---|
380 |
|
---|
381 | assertTrue('testSearchPath_Found', tmpResult);
|
---|
382 | assertEqualsString('testSearchPath_Found', 'C:\OS2\BOOK\CMDREF.INF', tmpResultFilename);
|
---|
383 | end;
|
---|
384 |
|
---|
385 |
|
---|
386 | Procedure testSearchPath_FoundMixedCase;
|
---|
387 | var
|
---|
388 | tmpResult : Boolean;
|
---|
389 | tmpResultFilename : String;
|
---|
390 | begin
|
---|
391 | tmpResult := SearchPath('BOOKSHELF', 'cMdRef.iNf', tmpResultFilename);
|
---|
392 |
|
---|
393 | assertTrue('testSearchPath_FoundMixedCase', tmpResult);
|
---|
394 | assertEqualsString('testSearchPath_FoundMixedCase', 'C:\OS2\BOOK\cMdRef.iNf', tmpResultFilename);
|
---|
395 | end;
|
---|
396 |
|
---|
397 |
|
---|
398 | Procedure testSearchPath_NotFound;
|
---|
399 | var
|
---|
400 | tmpResult : Boolean;
|
---|
401 | tmpResultFilename : String;
|
---|
402 | begin
|
---|
403 | tmpResult := SearchPath('BOOKSHELF', 'RBRi.INF', tmpResultFilename);
|
---|
404 |
|
---|
405 | assertFalse('testSearchPath_NotFound', tmpResult);
|
---|
406 | assertEqualsString('testSearchPath_NotFound', '', tmpResultFilename);
|
---|
407 | end;
|
---|
408 |
|
---|
409 |
|
---|
410 | Procedure testSearchPath_NotExistingEnvironment;
|
---|
411 | var
|
---|
412 | tmpResult : Boolean;
|
---|
413 | tmpResultFilename : String;
|
---|
414 | begin
|
---|
415 | tmpResult := SearchPath('BUECHER', 'RBRi.INF', tmpResultFilename);
|
---|
416 |
|
---|
417 | assertFalse('testSearchPath_NotExistingEnvironment', tmpResult);
|
---|
418 | assertEqualsString('testSearchPath_NotExistingEnvironment', '', tmpResultFilename);
|
---|
419 | end;
|
---|
420 |
|
---|
421 | // ----------------------------------------------------------
|
---|
422 |
|
---|
423 | Procedure testSearchHelpPaths_FoundBookshelf;
|
---|
424 | var
|
---|
425 | tmpResult : Boolean;
|
---|
426 | tmpResultFilename : String;
|
---|
427 | begin
|
---|
428 | tmpResult := SearchHelpPaths('CMDREF.INF', tmpResultFilename, false);
|
---|
429 |
|
---|
430 | assertTrue('testSearchHelpPaths_FoundBookshelf', tmpResult);
|
---|
431 | assertEqualsString('testSearchHelpPaths_FoundBookshelf', 'C:\OS2\BOOK\CMDREF.INF', tmpResultFilename);
|
---|
432 | end;
|
---|
433 |
|
---|
434 |
|
---|
435 | Procedure testSearchHelpPaths_FoundHelp;
|
---|
436 | var
|
---|
437 | tmpResult : Boolean;
|
---|
438 | tmpResultFilename : String;
|
---|
439 | begin
|
---|
440 | tmpResult := SearchHelpPaths('WPHELP.HLP', tmpResultFilename, false);
|
---|
441 |
|
---|
442 | assertTrue('testSearchHelpPaths_FoundHelp', tmpResult);
|
---|
443 | assertEqualsString('testSearchHelpPaths_FoundHelp', 'C:\OS2\HELP\WPHELP.HLP', tmpResultFilename);
|
---|
444 | end;
|
---|
445 |
|
---|
446 | { . is part of the helppath
|
---|
447 | Procedure testSearchHelpPaths_DontSearchInAppDir;
|
---|
448 | var
|
---|
449 | tmpResult : Boolean;
|
---|
450 | tmpResultFilename : String;
|
---|
451 | begin
|
---|
452 | tmpResult := SearchHelpPaths('NewViewTests.EXE', tmpResultFilename, False);
|
---|
453 |
|
---|
454 | assertFalse('testSearchHelpPaths_DontSearchInAppDir', tmpResult);
|
---|
455 | assertEqualsString('testSearchHelpPaths_DontSearchInAppDir', '', tmpResultFilename);
|
---|
456 | end;
|
---|
457 | }
|
---|
458 |
|
---|
459 | Procedure testSearchHelpPaths_FoundInAppDir;
|
---|
460 | var
|
---|
461 | tmpResult : Boolean;
|
---|
462 | tmpResultFilename : String;
|
---|
463 | begin
|
---|
464 | tmpResult := SearchHelpPaths('NewViewTests.EXE', tmpResultFilename, True);
|
---|
465 |
|
---|
466 | assertTrue('testSearchHelpPaths_FoundInAppDir', tmpResult);
|
---|
467 | assertEqualsString('testSearchHelpPaths_FoundInAppDir', TEST_PATH + '\build\unittest\NewViewTests.EXE', tmpResultFilename);
|
---|
468 | end;
|
---|
469 |
|
---|
470 |
|
---|
471 | Procedure testSearchHelpPaths_NotFoundInAppDir;
|
---|
472 | var
|
---|
473 | tmpResult : Boolean;
|
---|
474 | tmpResultFilename : String;
|
---|
475 | begin
|
---|
476 | tmpResult := SearchHelpPaths('NewView.EXE', tmpResultFilename, True);
|
---|
477 |
|
---|
478 | assertFalse('testSearchHelpPaths_NotFoundInAppDir', tmpResult);
|
---|
479 | assertEqualsString('testSearchHelpPaths_NotFoundInAppDir', '', tmpResultFilename);
|
---|
480 | end;
|
---|
481 |
|
---|
482 | // ----------------------------------------------------------
|
---|
483 |
|
---|
484 | Procedure testFindDefaultLanguageHelpFile;
|
---|
485 | var
|
---|
486 | tmpResult : String;
|
---|
487 | begin
|
---|
488 | tmpResult := FindDefaultLanguageHelpFile('NewView', '');
|
---|
489 |
|
---|
490 | assertEqualsString('testFindDefaultLanguageHelpFile', 'C:\ecs\help\NewView.hlp', tmpResult);
|
---|
491 | end;
|
---|
492 |
|
---|
493 | Procedure testFindDefaultLanguageHelpFile_it;
|
---|
494 | var
|
---|
495 | tmpResult : String;
|
---|
496 | begin
|
---|
497 | tmpResult := FindDefaultLanguageHelpFile('NewView', 'it');
|
---|
498 |
|
---|
499 | assertEqualsString('testFindDefaultLanguageHelpFile_it', 'C:\ecs\help\NewView_it.hlp', tmpResult);
|
---|
500 | end;
|
---|
501 |
|
---|
502 | Procedure testFindDefaultLanguageHelpFile_it_UpperCase;
|
---|
503 | var
|
---|
504 | tmpResult : String;
|
---|
505 | begin
|
---|
506 | tmpResult := FindDefaultLanguageHelpFile('NewView', 'IT');
|
---|
507 |
|
---|
508 | assertEqualsString('testFindDefaultLanguageHelpFile_it_UpperCase', 'C:\ecs\help\NewView_IT.hlp', tmpResult);
|
---|
509 | end;
|
---|
510 |
|
---|
511 |
|
---|
512 | // ----------------------------------------------------------
|
---|
513 |
|
---|
514 |
|
---|
515 | Procedure testGetDirsInPath_Unknown;
|
---|
516 | var
|
---|
517 | tmpResult : TStringList;
|
---|
518 | begin
|
---|
519 | tmpResult := TStringList.Create;
|
---|
520 | tmpResult.Add('Tester');
|
---|
521 |
|
---|
522 | GetDirsInPath('Unknown', tmpResult);
|
---|
523 |
|
---|
524 | assertEqualsInt('testGetDirsInPath_Unknown', 0, tmpResult.count);
|
---|
525 |
|
---|
526 | tmpResult.Destroy;
|
---|
527 | end;
|
---|
528 |
|
---|
529 |
|
---|
530 | Procedure testGetDirsInPath_Help;
|
---|
531 | var
|
---|
532 | tmpResult : TStringList;
|
---|
533 | begin
|
---|
534 | tmpResult := TStringList.Create;
|
---|
535 | tmpResult.Add('Tester');
|
---|
536 |
|
---|
537 | GetDirsInPath('HELP', tmpResult);
|
---|
538 |
|
---|
539 | assertEqualsInt('testGetDirsInPath_Help', 15, tmpResult.count);
|
---|
540 | assertEqualsString('testGetDirsInPath_Help', 'D:\progs\watcom\BINP\HELP', tmpResult[0]);
|
---|
541 | assertEqualsString('testGetDirsInPath_Help', 'd:\progs\SIBYL\BIN', tmpResult[14]);
|
---|
542 |
|
---|
543 | tmpResult.Destroy;
|
---|
544 | end;
|
---|
545 |
|
---|
546 | // ----------------------------------------------------------
|
---|
547 |
|
---|
548 | Procedure testListFilesInDirectory_NoFiles;
|
---|
549 | var
|
---|
550 | tmpResult : TStringList;
|
---|
551 | begin
|
---|
552 | tmpResult := TStringList.Create;
|
---|
553 |
|
---|
554 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.jonas', false, tmpResult);
|
---|
555 |
|
---|
556 | assertEqualsInt('testListFilesInDirectory_NoFiles', 0, tmpResult.count);
|
---|
557 | end;
|
---|
558 |
|
---|
559 |
|
---|
560 | Procedure testListFilesInDirectory_EmptyFilter;
|
---|
561 | var
|
---|
562 | tmpResult : TStringList;
|
---|
563 | begin
|
---|
564 | tmpResult := TStringList.Create;
|
---|
565 |
|
---|
566 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '', false, tmpResult);
|
---|
567 |
|
---|
568 | assertEqualsInt('testListFilesInDirectory_EmptyFilter', 0, tmpResult.count);
|
---|
569 |
|
---|
570 | tmpResult.Destroy;
|
---|
571 | end;
|
---|
572 |
|
---|
573 |
|
---|
574 | Procedure testListFilesInDirectory_OneFile;
|
---|
575 | var
|
---|
576 | tmpResult : TStringList;
|
---|
577 | begin
|
---|
578 | tmpResult := TStringList.Create;
|
---|
579 |
|
---|
580 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.txt', false, tmpResult);
|
---|
581 |
|
---|
582 | assertEqualsInt('testListFilesInDirectory_OneFile', 1, tmpResult.count);
|
---|
583 | assertEqualsString('testListFilesInDirectory_OneFile', 'readme.txt', tmpResult[0]);
|
---|
584 |
|
---|
585 | tmpResult.Destroy;
|
---|
586 | end;
|
---|
587 |
|
---|
588 |
|
---|
589 | Procedure testListFilesInDirectory_ManyFiles;
|
---|
590 | var
|
---|
591 | tmpResult : TStringList;
|
---|
592 | begin
|
---|
593 | tmpResult := TStringList.Create;
|
---|
594 |
|
---|
595 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.*', false, tmpResult);
|
---|
596 |
|
---|
597 | assertEqualsInt('testListFilesInDirectory_ManyFiles', 6, tmpResult.count);
|
---|
598 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file0', tmpResult[0]);
|
---|
599 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file1.ex1', tmpResult[1]);
|
---|
600 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file2.ex1', tmpResult[2]);
|
---|
601 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file3.ex3', tmpResult[3]);
|
---|
602 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file4.ext4', tmpResult[4]);
|
---|
603 |
|
---|
604 | tmpResult.Destroy;
|
---|
605 | end;
|
---|
606 |
|
---|
607 |
|
---|
608 | Procedure testListFilesInDirectory_ManyFilter;
|
---|
609 | var
|
---|
610 | tmpResult : TStringList;
|
---|
611 | begin
|
---|
612 | tmpResult := TStringList.Create;
|
---|
613 |
|
---|
614 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.txt;f*.ex1', false, tmpResult);
|
---|
615 |
|
---|
616 | assertEqualsInt('testListFilesInDirectory_ManyFilter', 3, tmpResult.count);
|
---|
617 | assertEqualsString('testListFilesInDirectory_ManyFilter', 'readme.txt', tmpResult[0]);
|
---|
618 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file1.ex1', tmpResult[1]);
|
---|
619 | assertEqualsString('testListFilesInDirectory_ManyFiles', 'file2.ex1', tmpResult[2]);
|
---|
620 |
|
---|
621 | tmpResult.Destroy;
|
---|
622 | end;
|
---|
623 |
|
---|
624 |
|
---|
625 | // ----------------------------------------------------------
|
---|
626 |
|
---|
627 |
|
---|
628 | Procedure testListFilesInDirectoryWithDirectoryInResult_NoFiles;
|
---|
629 | var
|
---|
630 | tmpResult : TStringList;
|
---|
631 | begin
|
---|
632 | tmpResult := TStringList.Create;
|
---|
633 |
|
---|
634 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.jonas', true, tmpResult);
|
---|
635 |
|
---|
636 | assertEqualsInt('testListFilesInDirectoryWithDirectoryInResult_NoFiles', 0, tmpResult.count);
|
---|
637 | end;
|
---|
638 |
|
---|
639 |
|
---|
640 | Procedure testListFilesInDirectoryWithDirectoryInResult_EmptyFilter;
|
---|
641 | var
|
---|
642 | tmpResult : TStringList;
|
---|
643 | begin
|
---|
644 | tmpResult := TStringList.Create;
|
---|
645 |
|
---|
646 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '', true, tmpResult);
|
---|
647 |
|
---|
648 | assertEqualsInt('testListFilesInDirectoryWithDirectoryInResult_EmptyFilter', 0, tmpResult.count);
|
---|
649 |
|
---|
650 | tmpResult.Destroy;
|
---|
651 | end;
|
---|
652 |
|
---|
653 |
|
---|
654 | Procedure testListFilesInDirectoryWithDirectoryInResult_OneFile;
|
---|
655 | var
|
---|
656 | tmpResult : TStringList;
|
---|
657 | begin
|
---|
658 | tmpResult := TStringList.Create;
|
---|
659 |
|
---|
660 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.txt', true, tmpResult);
|
---|
661 |
|
---|
662 | assertEqualsInt('testListFilesInDirectoryWithDirectoryInResult_OneFile', 1, tmpResult.count);
|
---|
663 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_OneFile', TEST_PATH + '\unittests\testdir' + '\readme.txt', tmpResult[0]);
|
---|
664 |
|
---|
665 | tmpResult.Destroy;
|
---|
666 | end;
|
---|
667 |
|
---|
668 |
|
---|
669 | Procedure testListFilesInDirectoryWithDirectoryInResult_ManyFiles;
|
---|
670 | var
|
---|
671 | tmpResult : TStringList;
|
---|
672 | begin
|
---|
673 | tmpResult := TStringList.Create;
|
---|
674 |
|
---|
675 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.*', true, tmpResult);
|
---|
676 |
|
---|
677 | assertEqualsInt('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', 6, tmpResult.count);
|
---|
678 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\file0', tmpResult[0]);
|
---|
679 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\file1.ex1', tmpResult[1]);
|
---|
680 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\file2.ex1', tmpResult[2]);
|
---|
681 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\file3.ex3', tmpResult[3]);
|
---|
682 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\file4.ext4', tmpResult[4]);
|
---|
683 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFiles', TEST_PATH + '\unittests\testdir' + '\readme.txt', tmpResult[5]);
|
---|
684 |
|
---|
685 | tmpResult.Destroy;
|
---|
686 | end;
|
---|
687 |
|
---|
688 |
|
---|
689 | Procedure testListFilesInDirectoryWithDirectoryInResult_ManyFilter;
|
---|
690 | var
|
---|
691 | tmpResult : TStringList;
|
---|
692 | begin
|
---|
693 | tmpResult := TStringList.Create;
|
---|
694 |
|
---|
695 | ListFilesInDirectory(TEST_PATH + '\unittests\testdir', '*.txt;f*.ex1', true, tmpResult);
|
---|
696 |
|
---|
697 | assertEqualsInt('testListFilesInDirectoryWithDirectoryInResult_ManyFilter', 3, tmpResult.count);
|
---|
698 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFilter', TEST_PATH + '\unittests\testdir' + '\readme.txt', tmpResult[0]);
|
---|
699 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFilter', TEST_PATH + '\unittests\testdir' + '\file1.ex1', tmpResult[1]);
|
---|
700 | assertEqualsString('testListFilesInDirectoryWithDirectoryInResult_ManyFilter', TEST_PATH + '\unittests\testdir' + '\file2.ex1', tmpResult[2]);
|
---|
701 |
|
---|
702 | tmpResult.Destroy;
|
---|
703 | end;
|
---|
704 |
|
---|
705 | // ----------------------------------------------------------
|
---|
706 |
|
---|
707 | Procedure testListSubDirectories_None;
|
---|
708 | var
|
---|
709 | tmpResult : TStringList;
|
---|
710 | begin
|
---|
711 | tmpResult := TStringList.Create;
|
---|
712 |
|
---|
713 | ListSubDirectories(TEST_PATH + '\unittests\testdir\subdir1', tmpResult);
|
---|
714 |
|
---|
715 | assertEqualsInt('testListSubDirectories_None', 0, tmpResult.count);
|
---|
716 |
|
---|
717 | tmpResult.Destroy;
|
---|
718 | end;
|
---|
719 |
|
---|
720 |
|
---|
721 | Procedure testListSubDirectories_Many;
|
---|
722 | var
|
---|
723 | tmpResult : TStringList;
|
---|
724 | begin
|
---|
725 | tmpResult := TStringList.Create;
|
---|
726 |
|
---|
727 | ListSubDirectories(TEST_PATH + '\unittests\testdir', tmpResult);
|
---|
728 |
|
---|
729 | assertEqualsInt('testListSubDirectories_Many', 1, tmpResult.count);
|
---|
730 | assertEqualsString('testListSubDirectories_Many', TEST_PATH + '\unittests\testdir\subdir1', tmpResult[0]);
|
---|
731 |
|
---|
732 | tmpResult.Destroy;
|
---|
733 | end;
|
---|
734 |
|
---|
735 |
|
---|
736 | // ----------------------------------------------------------
|
---|
737 |
|
---|
738 |
|
---|
739 | Procedure testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult;
|
---|
740 | var
|
---|
741 | tmpResult : TStringList;
|
---|
742 | begin
|
---|
743 | tmpResult := TStringList.Create;
|
---|
744 |
|
---|
745 | ListFilesInDirectoryRecursiveWithTermination(TEST_PATH + '\unittests\testdir', '*.ex1;ex2', true, tmpResult, nil, false);
|
---|
746 |
|
---|
747 | assertEqualsInt('testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult', 3, tmpResult.count);
|
---|
748 | assertEqualsString('testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult', TEST_PATH + '\unittests\testdir' + '\file1.ex1', tmpResult[0]);
|
---|
749 | assertEqualsString('testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult', TEST_PATH + '\unittests\testdir' + '\file2.ex1', tmpResult[1]);
|
---|
750 | assertEqualsString('testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult', TEST_PATH + '\unittests\testdir' + '\subdir1\file1.ex1', tmpResult[2]);
|
---|
751 |
|
---|
752 | tmpResult.Destroy;
|
---|
753 | end;
|
---|
754 |
|
---|
755 |
|
---|
756 | // ----------------------------------------------------------
|
---|
757 |
|
---|
758 |
|
---|
759 | Procedure testListFilesInDirectoryRecursiveWithTermination;
|
---|
760 | var
|
---|
761 | tmpResult : TStringList;
|
---|
762 | begin
|
---|
763 | tmpResult := TStringList.Create;
|
---|
764 |
|
---|
765 | ListFilesInDirectoryRecursiveWithTermination(TEST_PATH + '\unittests\testdir', '*.ex1;ex2', false, tmpResult, nil, false);
|
---|
766 |
|
---|
767 | assertEqualsInt('testListFilesInDirectoryRecursiveWithTermination', 3, tmpResult.count);
|
---|
768 | assertEqualsString('testListFilesInDirectoryRecursiveWithTermination', 'file1.ex1', tmpResult[0]);
|
---|
769 | assertEqualsString('testListFilesInDirectoryRecursiveWithTermination', 'file2.ex1', tmpResult[1]);
|
---|
770 | assertEqualsString('testListFilesInDirectoryRecursiveWithTermination', 'file1.ex1', tmpResult[2]);
|
---|
771 |
|
---|
772 | tmpResult.Destroy;
|
---|
773 | end;
|
---|
774 |
|
---|
775 |
|
---|
776 | // ----------------------------------------------------------
|
---|
777 |
|
---|
778 |
|
---|
779 | Procedure testParentDir_Empty;
|
---|
780 | var
|
---|
781 | tmpResult : String;
|
---|
782 | begin
|
---|
783 | tmpResult := ParentDir('');
|
---|
784 |
|
---|
785 | assertEqualsString('testParentDir_Empty', '', tmpResult);
|
---|
786 | end;
|
---|
787 |
|
---|
788 |
|
---|
789 | Procedure testParentDir_Root;
|
---|
790 | var
|
---|
791 | tmpResult : String;
|
---|
792 | begin
|
---|
793 | tmpResult := ParentDir('C:\');
|
---|
794 |
|
---|
795 | assertEqualsString('testParentDir_Root', '', tmpResult);
|
---|
796 | end;
|
---|
797 |
|
---|
798 |
|
---|
799 | Procedure testParentDir_UnixRoot;
|
---|
800 | var
|
---|
801 | tmpResult : String;
|
---|
802 | begin
|
---|
803 | tmpResult := ParentDir('\');
|
---|
804 |
|
---|
805 | assertEqualsString('testParentDir_UnixRoot', '', tmpResult);
|
---|
806 | end;
|
---|
807 |
|
---|
808 |
|
---|
809 | Procedure testParentDir;
|
---|
810 | var
|
---|
811 | tmpResult : String;
|
---|
812 | begin
|
---|
813 | tmpResult := ParentDir('\abc\def');
|
---|
814 |
|
---|
815 | assertEqualsString('testParentDir', '\abc', tmpResult);
|
---|
816 | end;
|
---|
817 |
|
---|
818 |
|
---|
819 | Procedure testParentDir_OnlyOne;
|
---|
820 | var
|
---|
821 | tmpResult : String;
|
---|
822 | begin
|
---|
823 | tmpResult := ParentDir('\abc');
|
---|
824 |
|
---|
825 | assertEqualsString('testParentDir_OnlyOne', '', tmpResult);
|
---|
826 | end;
|
---|
827 |
|
---|
828 |
|
---|
829 | Procedure testParentDir_SlashAtEnd;
|
---|
830 | var
|
---|
831 | tmpResult : String;
|
---|
832 | begin
|
---|
833 | tmpResult := ParentDir('\abc\def\');
|
---|
834 |
|
---|
835 | assertEqualsString('testParentDir_SlashAtEnd', '\abc', tmpResult);
|
---|
836 | end;
|
---|
837 |
|
---|
838 |
|
---|
839 | Procedure testParentDir_NoSlashAtStart;
|
---|
840 | var
|
---|
841 | tmpResult : String;
|
---|
842 | begin
|
---|
843 | tmpResult := ParentDir('abc\def\');
|
---|
844 |
|
---|
845 | assertEqualsString('testParentDir_NoSlashAtStart', 'abc', tmpResult);
|
---|
846 | end;
|
---|
847 |
|
---|
848 |
|
---|
849 | Procedure testParentDir_NoSlash;
|
---|
850 | var
|
---|
851 | tmpResult : String;
|
---|
852 | begin
|
---|
853 | tmpResult := ParentDir('abc');
|
---|
854 |
|
---|
855 | assertEqualsString('testParentDir_NoSlash', '', tmpResult);
|
---|
856 | end;
|
---|
857 |
|
---|
858 |
|
---|
859 | Procedure testParentDir_GoToRootDrive;
|
---|
860 | var
|
---|
861 | tmpResult : String;
|
---|
862 | begin
|
---|
863 | tmpResult := ParentDir('c:\abc');
|
---|
864 |
|
---|
865 | assertEqualsString('testParentDir_GoToRootDrive', 'c:', tmpResult);
|
---|
866 | end;
|
---|
867 |
|
---|
868 |
|
---|
869 | // ----------------------------------------------------------
|
---|
870 |
|
---|
871 |
|
---|
872 | Procedure testMakeDirs_Empty;
|
---|
873 | var
|
---|
874 | tmpResult : String;
|
---|
875 | begin
|
---|
876 | tmpResult := MakeDirs('');
|
---|
877 |
|
---|
878 | assertEqualsString('testMakeDirs_Empty', '', tmpResult);
|
---|
879 | end;
|
---|
880 |
|
---|
881 |
|
---|
882 | Procedure testMakeDirs_Slash;
|
---|
883 | var
|
---|
884 | tmpResult : String;
|
---|
885 | begin
|
---|
886 | tmpResult := MakeDirs('\');
|
---|
887 |
|
---|
888 | assertEqualsString('testMakeDirs_Slash', '', tmpResult);
|
---|
889 | end;
|
---|
890 |
|
---|
891 |
|
---|
892 | Procedure testMakeDirs_Simple;
|
---|
893 | var
|
---|
894 | tmpResult : String;
|
---|
895 | begin
|
---|
896 | RmDir(TEST_PATH + '\unittests\testdir\makedirs');
|
---|
897 |
|
---|
898 | tmpResult := MakeDirs(TEST_PATH + '\unittests\testdir' + '\makedirs');
|
---|
899 |
|
---|
900 | RmDir(TEST_PATH + '\unittests\testdir\makedirs');
|
---|
901 |
|
---|
902 | assertEqualsString('testMakeDirs_Simple', TEST_PATH + '\unittests\testdir\makedirs', tmpResult);
|
---|
903 | end;
|
---|
904 |
|
---|
905 |
|
---|
906 | Procedure testMakeDirs_Complex;
|
---|
907 | var
|
---|
908 | tmpResult : String;
|
---|
909 | begin
|
---|
910 | RmDir(TEST_PATH + '\unittests\testdir\makedirs\subdir\test');
|
---|
911 | RmDir(TEST_PATH + '\unittests\testdir\makedirs\subdir');
|
---|
912 | RmDir(TEST_PATH + '\unittests\testdir\makedirs');
|
---|
913 |
|
---|
914 | tmpResult := MakeDirs(TEST_PATH + '\unittests\testdir' + '\makedirs\subdir\test');
|
---|
915 |
|
---|
916 | RmDir(TEST_PATH + '\unittests\testdir\makedirs\subdir\test');
|
---|
917 | RmDir(TEST_PATH + '\unittests\testdir\makedirs\subdir');
|
---|
918 | RmDir(TEST_PATH + '\unittests\testdir\makedirs');
|
---|
919 |
|
---|
920 | assertEqualsString('testMakeDirs_Simple', TEST_PATH + '\unittests\testdir\makedirs\subdir\test', tmpResult);
|
---|
921 | end;
|
---|
922 |
|
---|
923 |
|
---|
924 | // ----------------------------------------------------------
|
---|
925 |
|
---|
926 |
|
---|
927 | Procedure testDirectoryExists_Empty;
|
---|
928 | var
|
---|
929 | tmpResult : Boolean;
|
---|
930 | begin
|
---|
931 | tmpResult := DirectoryExists('');
|
---|
932 |
|
---|
933 | assertTrue('testDirectoryExists_Empty', tmpResult);
|
---|
934 | end;
|
---|
935 |
|
---|
936 |
|
---|
937 | Procedure testDirectoryExists_DriveOnlyLowercase;
|
---|
938 | var
|
---|
939 | tmpResult : Boolean;
|
---|
940 | begin
|
---|
941 | tmpResult := DirectoryExists('c:');
|
---|
942 |
|
---|
943 | assertTrue('testDirectoryExists_DriveOnlyLowercase', tmpResult);
|
---|
944 | end;
|
---|
945 |
|
---|
946 |
|
---|
947 | Procedure testDirectoryExists_DriveOnlyUppercase;
|
---|
948 | var
|
---|
949 | tmpResult : Boolean;
|
---|
950 | begin
|
---|
951 | tmpResult := DirectoryExists('C:');
|
---|
952 |
|
---|
953 | assertTrue('testDirectoryExists_DriveOnlyUppercase', tmpResult);
|
---|
954 | end;
|
---|
955 |
|
---|
956 |
|
---|
957 | Procedure testDirectoryExists_DriveOnlySlashAtEnd;
|
---|
958 | var
|
---|
959 | tmpResult : Boolean;
|
---|
960 | begin
|
---|
961 | tmpResult := DirectoryExists('C:\');
|
---|
962 |
|
---|
963 | assertTrue('testDirectoryExists_DriveOnlySlashAtEnd', tmpResult);
|
---|
964 | end;
|
---|
965 |
|
---|
966 |
|
---|
967 | Procedure testDirectoryExists_DriveAndPath;
|
---|
968 | var
|
---|
969 | tmpResult : Boolean;
|
---|
970 | begin
|
---|
971 | tmpResult := DirectoryExists('C:\os2\bitmap');
|
---|
972 |
|
---|
973 | assertTrue('testDirectoryExists_DriveAndPath', tmpResult);
|
---|
974 | end;
|
---|
975 |
|
---|
976 |
|
---|
977 | Procedure testDirectoryExists_DriveAndPathSlashAtEnd;
|
---|
978 | var
|
---|
979 | tmpResult : Boolean;
|
---|
980 | begin
|
---|
981 | tmpResult := DirectoryExists('C:\os2\bitmap\');
|
---|
982 |
|
---|
983 | assertTrue('testDirectoryExists_DriveAndPathSlashAtEnd', tmpResult);
|
---|
984 | end;
|
---|
985 |
|
---|
986 |
|
---|
987 | Procedure testDirectoryExists_InvalidDrive;
|
---|
988 | var
|
---|
989 | tmpResult : Boolean;
|
---|
990 | begin
|
---|
991 | tmpResult := DirectoryExists('y:');
|
---|
992 |
|
---|
993 | assertFalse('testDirectoryExists_InvalidDrive', tmpResult);
|
---|
994 | end;
|
---|
995 |
|
---|
996 |
|
---|
997 | Procedure testDirectoryExists_InvalidDriveAndPath;
|
---|
998 | var
|
---|
999 | tmpResult : Boolean;
|
---|
1000 | begin
|
---|
1001 | tmpResult := DirectoryExists('y:\test');
|
---|
1002 |
|
---|
1003 | assertFalse('testDirectoryExists_InvalidDriveAndPath', tmpResult);
|
---|
1004 | end;
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | Procedure testDirectoryExists_NotExistent;
|
---|
1008 | var
|
---|
1009 | tmpResult : Boolean;
|
---|
1010 | begin
|
---|
1011 | tmpResult := DirectoryExists('C:\os2\bit\');
|
---|
1012 |
|
---|
1013 | assertFalse('testDirectoryExists_NotExistent', tmpResult);
|
---|
1014 | end;
|
---|
1015 |
|
---|
1016 |
|
---|
1017 | // ----------------------------------------------------------
|
---|
1018 |
|
---|
1019 |
|
---|
1020 | Procedure testDriveLetterToDriveNumber;
|
---|
1021 | var
|
---|
1022 | tmpResult : longint;
|
---|
1023 | begin
|
---|
1024 | tmpResult := DriveLetterToDriveNumber('A');
|
---|
1025 |
|
---|
1026 | assertEqualsInt('testDriveLetterToDriveNumber', 1, tmpResult);
|
---|
1027 | end;
|
---|
1028 |
|
---|
1029 |
|
---|
1030 | Procedure testDriveLetterToDriveNumber_LowerCase;
|
---|
1031 | var
|
---|
1032 | tmpResult : longint;
|
---|
1033 | begin
|
---|
1034 | tmpResult := DriveLetterToDriveNumber('a');
|
---|
1035 |
|
---|
1036 | assertEqualsInt('testDriveLetterToDriveNumber_LowerCase', 1, tmpResult);
|
---|
1037 | end;
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | Procedure testDriveLetterToDriveNumber_Unknown;
|
---|
1041 | var
|
---|
1042 | tmpResult : longint;
|
---|
1043 | begin
|
---|
1044 | tmpResult := DriveLetterToDriveNumber('');
|
---|
1045 |
|
---|
1046 | assertEqualsInt('testDriveLetterToDriveNumber_Unknown', 0, tmpResult);
|
---|
1047 | end;
|
---|
1048 |
|
---|
1049 |
|
---|
1050 | // ----------------------------------------------------------
|
---|
1051 |
|
---|
1052 |
|
---|
1053 | Procedure testDriveNumberToDriveLetter;
|
---|
1054 | begin
|
---|
1055 | assertEqualsString('testDriveNumberToDriveLetter 1', 'A', DriveNumberToDriveLetter(1));
|
---|
1056 | assertEqualsString('testDriveNumberToDriveLetter 2', 'B', DriveNumberToDriveLetter(2));
|
---|
1057 | end;
|
---|
1058 |
|
---|
1059 |
|
---|
1060 | // ----------------------------------------------------------
|
---|
1061 |
|
---|
1062 |
|
---|
1063 | Procedure testGetBootDriveLetter;
|
---|
1064 | var
|
---|
1065 | tmpResult : char;
|
---|
1066 | begin
|
---|
1067 | tmpResult := GetBootDriveLetter;
|
---|
1068 |
|
---|
1069 | assertEqualsString('testGetBootDriveLetter', 'C', tmpResult);
|
---|
1070 | end;
|
---|
1071 |
|
---|
1072 |
|
---|
1073 | // ----------------------------------------------------------
|
---|
1074 |
|
---|
1075 |
|
---|
1076 | Procedure testFileIsReadOnly_False;
|
---|
1077 | var
|
---|
1078 | tmpResult : boolean;
|
---|
1079 | begin
|
---|
1080 | tmpResult := FileIsReadOnly(GetBootDriveLetter + ':\config.sys');
|
---|
1081 |
|
---|
1082 | assertFalse('testFileIsReadOnly_False', tmpResult);
|
---|
1083 | end;
|
---|
1084 |
|
---|
1085 |
|
---|
1086 | Procedure testFileIsReadOnly_True;
|
---|
1087 | var
|
---|
1088 | tmpResult : boolean;
|
---|
1089 | begin
|
---|
1090 | tmpResult := FileIsReadOnly(GetBootDriveLetter + ':\os2ldr');
|
---|
1091 |
|
---|
1092 | assertTrue('testFileIsReadOnly_True', tmpResult);
|
---|
1093 | end;
|
---|
1094 |
|
---|
1095 |
|
---|
1096 | // ----------------------------------------------------------
|
---|
1097 |
|
---|
1098 |
|
---|
1099 | Function getFileUtilsUnitTests : TList;
|
---|
1100 | Begin
|
---|
1101 | result := TList.Create;
|
---|
1102 |
|
---|
1103 | result.add(@testAddDirectorySeparator_Empty);
|
---|
1104 | result.add(@testAddDirectorySeparator_SingleChar);
|
---|
1105 | result.add(@testAddDirectorySeparator_ManyChars);
|
---|
1106 | result.add(@testAddDirectorySeparator_SlashAtEnd);
|
---|
1107 |
|
---|
1108 | result.add(@testAddDirectorySeparatorIfNotEmpty_Empty);
|
---|
1109 | result.add(@testAddDirectorySeparatorIfNotEmpty_SingleChar);
|
---|
1110 | result.add(@testAddDirectorySeparatorIfNotEmpty_ManyChars);
|
---|
1111 | result.add(@testAddDirectorySeparatorIfNotEmpty_SlashAtEnd);
|
---|
1112 |
|
---|
1113 | result.add(@testRemoveRightDirectorySeparator_Empty);
|
---|
1114 | result.add(@testRemoveRightDirectorySeparator_WithoutSlash);
|
---|
1115 | result.add(@testRemoveRightDirectorySeparator_WithSlash);
|
---|
1116 |
|
---|
1117 | result.add(@testExpandPath_BothEmpty);
|
---|
1118 | result.add(@testExpandPath_PathEmpty);
|
---|
1119 | result.add(@testExpandPath_PathEmptyDirEndsWithSlash);
|
---|
1120 | result.add(@testExpandPath_AbsolutePath);
|
---|
1121 | result.add(@testExpandPath_DriveWithSlash);
|
---|
1122 | result.add(@testExpandPath_DriveWithoutSlash);
|
---|
1123 | result.add(@testExpandPath_RootPathForDrive);
|
---|
1124 | result.add(@testExpandPath_RootDirForDrive);
|
---|
1125 | result.add(@testExpandPath_RootPathWithoutDrive);
|
---|
1126 | result.add(@testExpandPath_RootDirWithoutDrive);
|
---|
1127 | result.add(@testExpandPath_AppendWithSlash);
|
---|
1128 | result.add(@testExpandPath_AppendWithoutSlash);
|
---|
1129 | result.add(@testExpandPath_AppendWithSlashAtEnd);
|
---|
1130 | result.add(@testExpandPath_WithDot);
|
---|
1131 | result.add(@testExpandPath_WithDotAtEnd);
|
---|
1132 | result.add(@testExpandPath_WithDots);
|
---|
1133 | result.add(@testExpandPath_WithDotsAtEnd);
|
---|
1134 | result.add(@testExpandPath_WithDotsInFront);
|
---|
1135 | result.add(@testExpandPath_WithDotsInFrontReachingRoot);
|
---|
1136 | result.add(@testExpandPath_WithDotsInFrontReachingDrive);
|
---|
1137 | result.add(@testExpandPath_WithDotsInFrontLeavingRoot);
|
---|
1138 | result.add(@testExpandPath_WithDotsInFrontLeavingDrive);
|
---|
1139 |
|
---|
1140 | result.add(@testGetLogFilesDir);
|
---|
1141 |
|
---|
1142 | result.add(@testSearchPath_Found);
|
---|
1143 | result.add(@testSearchPath_FoundMixedCase);
|
---|
1144 | result.add(@testSearchPath_NotFound);
|
---|
1145 | result.add(@testSearchPath_NotExistingEnvironment);
|
---|
1146 |
|
---|
1147 | result.add(@testSearchHelpPaths_FoundBookshelf);
|
---|
1148 | result.add(@testSearchHelpPaths_FoundHelp);
|
---|
1149 | // result.add(@testSearchHelpPaths_DontSearchInAppDir);
|
---|
1150 | result.add(@testSearchHelpPaths_FoundInAppDir);
|
---|
1151 | result.add(@testSearchHelpPaths_NotFoundInAppDir);
|
---|
1152 |
|
---|
1153 | result.add(@testFindDefaultLanguageHelpFile);
|
---|
1154 | result.add(@testFindDefaultLanguageHelpFile_it);
|
---|
1155 | result.add(@testFindDefaultLanguageHelpFile_it_UpperCase);
|
---|
1156 |
|
---|
1157 | result.add(@testGetDirsInPath_Unknown);
|
---|
1158 | result.add(@testGetDirsInPath_Help);
|
---|
1159 |
|
---|
1160 | result.add(@testListFilesInDirectory_NoFiles);
|
---|
1161 | result.add(@testListFilesInDirectory_EmptyFilter);
|
---|
1162 | result.add(@testListFilesInDirectory_OneFile);
|
---|
1163 | result.add(@testListFilesInDirectory_ManyFiles);
|
---|
1164 | result.add(@testListFilesInDirectory_ManyFilter);
|
---|
1165 | result.add(@testListFilesInDirectoryWithDirectoryInResult_NoFiles);
|
---|
1166 | result.add(@testListFilesInDirectoryWithDirectoryInResult_EmptyFilter);
|
---|
1167 | result.add(@testListFilesInDirectoryWithDirectoryInResult_OneFile);
|
---|
1168 | result.add(@testListFilesInDirectoryWithDirectoryInResult_ManyFiles);
|
---|
1169 | result.add(@testListFilesInDirectoryWithDirectoryInResult_ManyFilter);
|
---|
1170 |
|
---|
1171 | result.add(@testListSubDirectories_None);
|
---|
1172 | result.add(@testListSubDirectories_Many);
|
---|
1173 |
|
---|
1174 | result.add(@testListFilesInDirectoryRecursiveWithTermination);
|
---|
1175 | result.add(@testListFilesInDirectoryRecursiveWithTerminationWithDirectoryInResult);
|
---|
1176 |
|
---|
1177 | result.add(@testParentDir_Empty);
|
---|
1178 | result.add(@testParentDir_Root);
|
---|
1179 | result.add(@testParentDir_UnixRoot);
|
---|
1180 | result.add(@testParentDir);
|
---|
1181 | result.add(@testParentDir_OnlyOne);
|
---|
1182 | result.add(@testParentDir_SlashAtEnd);
|
---|
1183 | result.add(@testParentDir_NoSlashAtStart);
|
---|
1184 | result.add(@testParentDir_NoSlash);
|
---|
1185 | result.add(@testParentDir_GoToRootDrive);
|
---|
1186 |
|
---|
1187 | result.add(@testMakeDirs_Empty);
|
---|
1188 | result.add(@testMakeDirs_Slash);
|
---|
1189 | result.add(@testMakeDirs_Simple);
|
---|
1190 | result.add(@testMakeDirs_Complex);
|
---|
1191 |
|
---|
1192 | result.add(@testDirectoryExists_Empty);
|
---|
1193 | result.add(@testDirectoryExists_DriveOnlyLowercase);
|
---|
1194 | result.add(@testDirectoryExists_DriveOnlyUppercase);
|
---|
1195 | result.add(@testDirectoryExists_DriveOnlySlashAtEnd);
|
---|
1196 | result.add(@testDirectoryExists_DriveAndPath);
|
---|
1197 | result.add(@testDirectoryExists_DriveAndPathSlashAtEnd);
|
---|
1198 | result.add(@testDirectoryExists_InvalidDrive);
|
---|
1199 | result.add(@testDirectoryExists_InvalidDriveAndPath);
|
---|
1200 | result.add(@testDirectoryExists_NotExistent);
|
---|
1201 |
|
---|
1202 | result.add(@testDriveLetterToDriveNumber);
|
---|
1203 | result.add(@testDriveLetterToDriveNumber_LowerCase);
|
---|
1204 | result.add(@testDriveLetterToDriveNumber_Unknown);
|
---|
1205 |
|
---|
1206 | result.add(@testDriveNumberToDriveLetter);
|
---|
1207 |
|
---|
1208 | result.add(@testGetBootDriveLetter);
|
---|
1209 |
|
---|
1210 | result.add(@testFileIsReadOnly_False);
|
---|
1211 | result.add(@testFileIsReadOnly_True);
|
---|
1212 |
|
---|
1213 | end;
|
---|
1214 |
|
---|
1215 | End.
|
---|