tests: added some file related tests

git-svn-id: trunk@15258 -
This commit is contained in:
vincents 2008-05-27 12:06:31 +00:00
parent 5c7e0b9f07
commit 31c6ff80ad
6 changed files with 91 additions and 10 deletions

1
.gitattributes vendored
View File

@ -3636,6 +3636,7 @@ test/bugs/8450/unit1.lfm svneol=native#text/plain
test/bugs/8450/unit1.lrs svneol=native#text/plain
test/bugs/8450/unit1.pas svneol=native#text/plain
test/bugs/bug8432.pas svneol=native#text/plain
test/bugs/testfileproc.pas svneol=native#text/plain
test/bugs/testfileutil.pas svneol=native#text/plain
test/bugtestcase.pas svneol=native#text/plain
test/hello.ahk svneol=native#text/plain

View File

@ -0,0 +1,54 @@
unit testfileproc;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testglobals,
FileProcs;
type
{ TTestFileUtil }
TTestFileProc= class(TTestCase)
published
procedure TestFileIsExecutable;
procedure TestTrimFileName;
end;
implementation
{ TTestFileProc }
procedure TTestFileProc.TestFileIsExecutable;
procedure DoTest(const AFileName: string; Expected: boolean);
begin
AssertEquals(AFileName, Expected, FileIsExecutable(AFileName));
end;
begin
DoTest(ParamStr(0),true);
// a directory is not an executable file
DoTest(ExtractFileDir(ParamStr(0)), false);
end;
procedure TTestFileProc.TestTrimFileName;
procedure DoTest(AFileName, Expected: string);
begin
DoDirSeparators(AFileName);
DoDirSeparators(Expected);
AssertEquals(AFileName, Expected, TrimFilename(AFileName));
end;
begin
{$ifdef windows}
DoTest('c:\LazarusDir\..\dir\','c:\dir\');
{$endif}
DoTest('$(LazarusDir)\..\dir\','$(LazarusDir)\..\dir\');
end;
initialization
// TODO: Maybe this test case should be moved to another testsuite, e.g. codetools test
AddToBugsTestSuite(TTestSuite.Create(TTestFileProc, 'TestFileProc'));
end.

View File

@ -16,6 +16,7 @@ type
published
procedure TestFileIsExecutable;
procedure TestExtractFileNameWithoutExt;
procedure TestTrimFileName;
end;
implementation
@ -48,6 +49,20 @@ begin
DoTest(DirName + 'test.pas.bak', DirName + 'test');
end;
procedure TTestFileUtil.TestTrimFileName;
procedure DoTest(AFileName, Expected: string);
begin
DoDirSeparators(AFileName);
DoDirSeparators(Expected);
AssertEquals(AFileName, Expected, TrimFilename(AFileName));
end;
begin
{$ifdef windows}
DoTest('c:\LazarusDir\..\dir\','c:\dir\');
{$endif}
DoTest('$(LazarusDir)\..\dir\','$(LazarusDir)\..\dir\');
end;
initialization
// Maybe this test case should be moved to another testsuite, e.g. lcl test
AddToBugsTestSuite(TTestSuite.Create(TTestFileUtil, 'TestFileUtil'));

View File

@ -21,16 +21,19 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<RequiredPackages Count="4">
<Item1>
<PackageName Value="FCL"/>
<PackageName Value="CodeTools"/>
</Item1>
<Item2>
<PackageName Value="fpcunitconsolerunner"/>
<PackageName Value="FCL"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
<PackageName Value="fpcunitconsolerunner"/>
</Item3>
<Item4>
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="4">
<Unit0>

View File

@ -21,18 +21,21 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<RequiredPackages Count="4">
<Item1>
<PackageName Value="FCL"/>
<PackageName Value="CodeTools"/>
</Item1>
<Item2>
<PackageName Value="FPCUnitTestRunner"/>
<PackageName Value="FCL"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
<PackageName Value="FPCUnitTestRunner"/>
</Item3>
<Item4>
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="6">
<Units Count="7">
<Unit0>
<Filename Value="runtestsgui.lpr"/>
<IsPartOfProject Value="True"/>
@ -63,6 +66,11 @@
<IsPartOfProject Value="True"/>
<UnitName Value="testunits"/>
</Unit5>
<Unit6>
<Filename Value="bugs\testfileproc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testfileproc"/>
</Unit6>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -28,7 +28,7 @@ interface
uses
TestLpi, BugTestCase,
bug8432, testfileutil;
bug8432, testfileutil, testfileproc;
implementation