test: added test for FileUtil.FileIsExecutable

git-svn-id: trunk@10715 -
This commit is contained in:
vincents 2007-03-07 21:56:22 +00:00
parent f5b6a2e3ba
commit 6d5981f315
8 changed files with 98 additions and 4 deletions

2
.gitattributes vendored
View File

@ -2903,6 +2903,7 @@ test/bugs/8437/unit1.lfm svneol=native#text/plain
test/bugs/8437/unit1.lrs svneol=native#text/pascal
test/bugs/8437/unit1.pas svneol=native#text/pascal
test/bugs/bug8432.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
test/readme.txt svneol=native#text/plain
@ -2912,6 +2913,7 @@ test/runtestsgui.lpi svneol=native#text/plain
test/runtestsgui.lpr svneol=native#text/plain
test/testglobals.pas svneol=native#text/plain
test/testlpi.pas svneol=native#text/plain
test/testunits.pas svneol=native#text/plain
tools/apiwizz/apiwizard.lfm svneol=native#text/plain
tools/apiwizz/apiwizard.lrs svneol=native#text/pascal
tools/apiwizz/apiwizard.pp svneol=native#text/pascal

View File

@ -131,6 +131,6 @@ begin
end;
initialization
BugsTestSuite.AddTest(TTestSuite.Create(TTestBug8432, '8432'));
AddToBugsTestSuite(TTestSuite.Create(TTestBug8432, '8432'));
end.

View File

@ -0,0 +1,39 @@
unit testfileutil;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testglobals,
FileUtil;
type
{ TTestFileUtil }
TTestFileUtil= class(TTestCase)
published
procedure TestFileIsExecutable;
end;
implementation
{ TTestFileUtil }
procedure TTestFileUtil.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;
initialization
// Maybe this test case should be moved to another testsuite, e.g. lcl test
AddToBugsTestSuite(TTestSuite.Create(TTestFileUtil, 'TestFileUtil'));
end.

View File

@ -22,7 +22,7 @@ program runtests;
uses
Classes, consoletestrunner,
testglobals, TestLpi, BugTestCase;
testglobals, testunits;
type

View File

@ -32,7 +32,7 @@
<PackageName Value="FCL"/>
</Item3>
</RequiredPackages>
<Units Count="4">
<Units Count="6">
<Unit0>
<Filename Value="runtestsgui.lpr"/>
<IsPartOfProject Value="True"/>
@ -53,6 +53,16 @@
<IsPartOfProject Value="True"/>
<UnitName Value="bug8432"/>
</Unit3>
<Unit4>
<Filename Value="bugs\testfileutil.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testfileutil"/>
</Unit4>
<Unit5>
<Filename Value="testunits.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testunits"/>
</Unit5>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -23,7 +23,7 @@ program runtestsgui;
uses
Interfaces, Forms,
GuiTestRunner,
TestLpi, BugTestCase, bug8432;
testunits;
begin
Application.Title:='Run Lazarus tests';

View File

@ -28,9 +28,16 @@ uses
var
Compiler: string;
BugsTestSuite: TTestSuite;
procedure AddToBugsTestSuite(ATest: TTest);
implementation
procedure AddToBugsTestSuite(ATest: TTest);
begin
BugsTestSuite.AddTest(ATest);
end;
initialization
BugsTestSuite := TTestSuite.Create('Bugs');
GetTestRegistry.AddTest(BugsTestSuite);

36
test/testunits.pas Normal file
View File

@ -0,0 +1,36 @@
{ $Id: runtestsgui.lpr 10703 2007-03-02 15:39:03Z vincents $}
{ Copyright (C) 2006 Vincent Snijders
This unit is use both by the console test runner and the gui test runner.
Its main purpose is to include all test units, so that they will register
their tests.
This source is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This code is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
A copy of the GNU General Public License is available on the World Wide Web
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
}
unit testunits;
{$mode objfpc}{$H+}
interface
uses
TestLpi, BugTestCase,
bug8432, testfileutil;
implementation
end.