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