diff --git a/test/bugs/testfileproc.pas b/test/bugs/testfileproc.pas index 6b8ff80988..4b28223ca6 100644 --- a/test/bugs/testfileproc.pas +++ b/test/bugs/testfileproc.pas @@ -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')); diff --git a/test/runtests.lpr b/test/runtests.lpr index 771a340b83..e4feaf1422 100644 --- a/test/runtests.lpr +++ b/test/runtests.lpr @@ -69,7 +69,7 @@ end; procedure TLazTestRunner.WriteCustomHelp; begin writeln(' --compiler= use ppcxxx to build test projects'); - writeln(' --pcp= pass primarty-config-path to lazbuild'); + writeln(' --pcp= 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;