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