| 1 |
// -*- compile-command: "./test_single_testcase.sh TTestCastleFindFiles" -*- |
| 2 |
{ |
| 3 |
Copyright 2021-2023 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{ Test CastleFindFiles unit. } |
| 18 |
unit TestCastleFindFiles; |
| 19 |
|
| 20 |
interface |
| 21 |
|
| 22 |
uses |
| 23 |
Classes, SysUtils, CastleTester; |
| 24 |
|
| 25 |
type |
| 26 |
TTestCastleFindFiles = class(TCastleTestCase) |
| 27 |
published |
| 28 |
procedure TestNilHandler; |
| 29 |
procedure TestFindFirstCaseSensitive; |
| 30 |
end; |
| 31 |
|
| 32 |
implementation |
| 33 |
|
| 34 |
uses CastleFindFiles, CastleUriUtils; |
| 35 |
|
| 36 |
procedure TTestCastleFindFiles.TestNilHandler; |
| 37 |
begin |
| 38 |
AssertEquals(4, FindFiles('castle-data:/designs_to_count_files/', '*.castle-user-interface', false, nil, [ffRecursive])); |
| 39 |
end; |
| 40 |
|
| 41 |
procedure TTestCastleFindFiles.TestFindFirstCaseSensitive; |
| 42 |
var |
| 43 |
FileInfo: TFileInfo; |
| 44 |
DataLocalSystem: String; |
| 45 |
begin |
| 46 |
AssertTrue(FindFirstFile('castle-data:/designs_to_count_files/', '*.castle-user-interface', false, [], FileInfo)); |
| 47 |
AssertTrue(FindFirstFileIgnoreCase('castle-data:/designs_to_count_files/', '*.castle-user-interface', false, [], FileInfo)); |
| 48 |
|
| 49 |
// depends on OS, and whether castle-data contents are defined in XML |
| 50 |
//AssertTrue(FindFirstFile('castle-data:/designs_to_count_files/', '*.CASTLE-user-interface', false, [], FileInfo)); |
| 51 |
|
| 52 |
// guaranteed to be true in all situations |
| 53 |
AssertTrue(FindFirstFileIgnoreCase('castle-data:/designs_to_count_files/', '*.CASTLE-user-interface', false, [], FileInfo)); |
| 54 |
|
| 55 |
DataLocalSystem := UriToFilenameSafe(ResolveCastleDataUrl('castle-data:/')); |
| 56 |
|
| 57 |
if DataLocalSystem <> '' then |
| 58 |
begin |
| 59 |
//Writeln(DataLocalSystem); |
| 60 |
AssertTrue(FindFirstFile(DataLocalSystem + 'designs_to_count_files/', '*.castle-user-interface', false, [], FileInfo)); |
| 61 |
AssertTrue(FindFirstFileIgnoreCase(DataLocalSystem + 'designs_to_count_files/', '*.castle-user-interface', false, [], FileInfo)); |
| 62 |
|
| 63 |
// depends on OS, and whether castle-data contents are defined in XML |
| 64 |
//AssertTrue(FindFirstFile(DataLocalSystem + 'designs_to_count_files/', '*.CASTLE-user-interface')); |
| 65 |
|
| 66 |
// guaranteed to be true in all situations |
| 67 |
AssertTrue(FindFirstFileIgnoreCase(DataLocalSystem + 'designs_to_count_files/', '*.CASTLE-user-interface', false, [], FileInfo)); |
| 68 |
end; |
| 69 |
end; |
| 70 |
|
| 71 |
initialization |
| 72 |
RegisterTest(TTestCastleFindFiles); |
| 73 |
end. |