test: added TestCreateRelativePath

git-svn-id: trunk@28993 -
This commit is contained in:
mattias 2011-01-13 15:06:21 +00:00
parent e372929332
commit ca536d0252
2 changed files with 38 additions and 1 deletions

View File

@ -12,10 +12,13 @@ type
{ TTestFileUtil }
{ TTestFileProc }
TTestFileProc= class(TTestCase)
published
procedure TestFileIsExecutable;
procedure TestTrimFileName;
procedure TestCreateRelativePath;
end;
implementation
@ -47,6 +50,40 @@ begin
DoTest('$(LazarusDir)\..\dir\','$(LazarusDir)\..\dir\');
end;
procedure TTestFileProc.TestCreateRelativePath;
procedure DoTest(Filename, BaseDirectory, Expected: string;
UsePointDirectory: boolean = false);
begin
DoDirSeparators(Filename);
DoDirSeparators(BaseDirectory);
DoDirSeparators(Expected);
AssertEquals('CreateRelativePath(File='+Filename+',Base='+BaseDirectory+')',
Expected,
CreateRelativePath(Filename,BaseDirectory,UsePointDirectory));
end;
begin
DoTest('/a','/a','');
DoTest('/a','/a/','');
DoTest('/a/b','/a/b','');
DoTest('/a/b','/a/b/','');
DoTest('/a','/a/','');
DoTest('/a','','/a');
DoTest('/a/b','/a','b');
DoTest('/a/b','/a/','b');
DoTest('/a/b','/a//','b');
DoTest('/a','/a/b','../');
DoTest('/a','/a/b/','../');
DoTest('/a','/a/b//','../');
DoTest('/a/','/a/b','../');
DoTest('/a','/a/b/c','../../');
DoTest('/a','/a/b//c','../../');
DoTest('/a','/a//b/c','../../');
DoTest('/a','/a//b/c/','../../');
DoTest('/a','/b','/a');
end;
initialization
// TODO: Maybe this test case should be moved to another testsuite, e.g. codetools test
AddToBugsTestSuite(TTestSuite.Create(TTestFileProc, 'TestFileProc'));

View File

@ -69,7 +69,7 @@ end;
procedure TLazTestRunner.WriteCustomHelp;
begin
writeln(' --compiler=<ppcxxx> use ppcxxx to build test projects');
writeln(' --pcp=<primarty-config-path> pass primarty-config-path to lazbuild');
writeln(' --pcp=<primary-config-path> pass primary-config-path to lazbuild');
writeln(' --submitter=SubmitterName name of sumbitter of the test results');
writeln(' --machine=MachineName name of the machine the test runs on');
end;