-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a38fc07
commit a276082
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
unit txArchives; | ||
|
||
interface | ||
|
||
// public testing interface | ||
procedure BuildArchiveTests; | ||
|
||
implementation | ||
|
||
uses | ||
SysUtils, Classes, | ||
Mahogany, | ||
{$IFDEF USE_DLL} | ||
txImports, | ||
{$ENDIF} | ||
{$IFNDEF USE_DLL} | ||
xeArchives, xeMeta, | ||
{$ENDIF} | ||
txMeta; | ||
|
||
|
||
procedure TestGetContainerFiles(container, filter: PWideChar; expectedFiles: Integer); | ||
var | ||
len: Integer; | ||
sl: TStringList; | ||
begin | ||
ExpectSuccess(GetContainerFiles(PWideChar(container), filter, @len)); | ||
sl := TStringList.Create; | ||
try | ||
sl.Text := grs(len); | ||
ExpectEqual(sl.Count, expectedFiles, Format('There should be %d files in %s', | ||
[expectedFiles, container])); | ||
finally | ||
sl.Free; | ||
end; | ||
end; | ||
|
||
procedure BuildArchiveTests; | ||
var | ||
len: Integer; | ||
dataPath, container: String; | ||
begin | ||
Describe('Archive Functions', procedure | ||
begin | ||
BeforeAll(procedure | ||
begin | ||
ExpectSuccess(GetGlobal('DataPath', @len)); | ||
dataPath := grs(len); | ||
end); | ||
|
||
Describe('GetContainerFiles', procedure | ||
begin | ||
It('Should fail if the container is not loaded', procedure | ||
begin | ||
ExpectFailure(GetContainerFiles('blah', '', @len)); | ||
end); | ||
|
||
It('Should return files in container', procedure | ||
begin | ||
container := dataPath + 'Skyrim - Shaders.bsa'; | ||
TestGetContainerFiles(PWideChar(container), '', 122); | ||
end); | ||
|
||
It('Should filter properly', procedure | ||
begin | ||
container := dataPath + 'Skyrim - Textures.bsa'; | ||
TestGetContainerFiles(PWideChar(container), 'textures\sky\', 47); | ||
end); | ||
end); | ||
end); | ||
end; | ||
|
||
end. |