From 6d5981f31512011528ced03076b177fae4a0e0ba Mon Sep 17 00:00:00 2001 From: vincents Date: Wed, 7 Mar 2007 21:56:22 +0000 Subject: [PATCH] test: added test for FileUtil.FileIsExecutable git-svn-id: trunk@10715 - --- .gitattributes | 2 ++ test/bugs/bug8432.pas | 2 +- test/bugs/testfileutil.pas | 39 ++++++++++++++++++++++++++++++++++++++ test/runtests.lpr | 2 +- test/runtestsgui.lpi | 12 +++++++++++- test/runtestsgui.lpr | 2 +- test/testglobals.pas | 7 +++++++ test/testunits.pas | 36 +++++++++++++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 test/bugs/testfileutil.pas create mode 100644 test/testunits.pas diff --git a/.gitattributes b/.gitattributes index 8c04f4bc55..ef5b1b3e6d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/test/bugs/bug8432.pas b/test/bugs/bug8432.pas index df571b63bc..944f2ade17 100644 --- a/test/bugs/bug8432.pas +++ b/test/bugs/bug8432.pas @@ -131,6 +131,6 @@ begin end; initialization - BugsTestSuite.AddTest(TTestSuite.Create(TTestBug8432, '8432')); + AddToBugsTestSuite(TTestSuite.Create(TTestBug8432, '8432')); end. diff --git a/test/bugs/testfileutil.pas b/test/bugs/testfileutil.pas new file mode 100644 index 0000000000..14541de73a --- /dev/null +++ b/test/bugs/testfileutil.pas @@ -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. + diff --git a/test/runtests.lpr b/test/runtests.lpr index b153351ea9..e39b8114ce 100644 --- a/test/runtests.lpr +++ b/test/runtests.lpr @@ -22,7 +22,7 @@ program runtests; uses Classes, consoletestrunner, - testglobals, TestLpi, BugTestCase; + testglobals, testunits; type diff --git a/test/runtestsgui.lpi b/test/runtestsgui.lpi index 94243d7f0b..3d4bdd340c 100644 --- a/test/runtestsgui.lpi +++ b/test/runtestsgui.lpi @@ -32,7 +32,7 @@ - + @@ -53,6 +53,16 @@ + + + + + + + + + + diff --git a/test/runtestsgui.lpr b/test/runtestsgui.lpr index e6ec17a62f..5e1606d0fb 100644 --- a/test/runtestsgui.lpr +++ b/test/runtestsgui.lpr @@ -23,7 +23,7 @@ program runtestsgui; uses Interfaces, Forms, GuiTestRunner, - TestLpi, BugTestCase, bug8432; + testunits; begin Application.Title:='Run Lazarus tests'; diff --git a/test/testglobals.pas b/test/testglobals.pas index 815848b456..eaf1eec62c 100644 --- a/test/testglobals.pas +++ b/test/testglobals.pas @@ -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); diff --git a/test/testunits.pas b/test/testunits.pas new file mode 100644 index 0000000000..c0d2a4b668 --- /dev/null +++ b/test/testunits.pas @@ -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 . 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. +