mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 01:48:03 +02:00
codetools: added test for merging header files
git-svn-id: trunk@29842 -
This commit is contained in:
parent
e8de399c71
commit
9d9e320412
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -5759,6 +5759,7 @@ test/bugs/testfileutil.pas svneol=native#text/plain
|
||||
test/bugtestcase.pas svneol=native#text/plain
|
||||
test/codetoolstests/testbasiccodetools.pas svneol=native#text/plain
|
||||
test/codetoolstests/testcompleteblock.pas svneol=native#text/plain
|
||||
test/codetoolstests/testcth2pas.pas svneol=native#text/pascal
|
||||
test/codetoolstests/testctrangescan.pas svneol=native#text/plain
|
||||
test/codetoolstests/testctxmlfixfragments.pas svneol=native#text/pascal
|
||||
test/hello.ahk svneol=native#text/plain
|
||||
|
@ -656,9 +656,7 @@ var
|
||||
if length(Line)<length('#include')+2 then continue;
|
||||
if copy(Line,1,length('#include'))<>'#include' then continue;
|
||||
if not (Line[length('#include')+1] in [' ',#9]) then continue;
|
||||
debugln(['Parse AAA0 "',Line,'"']);
|
||||
IncludeParam:=Trim(copy(Line,length('#include')+1,length(Line)));
|
||||
debugln(['Parse AAA1 ',IncludeParam]);
|
||||
if (IncludeParam<>'') and (IncludeParam[1] in ['<','"']) then
|
||||
IncludeParam:=copy(IncludeParam,2,length(IncludeParam)-2);
|
||||
if IncludeParam<>'' then begin
|
||||
|
73
test/codetoolstests/testcth2pas.pas
Normal file
73
test/codetoolstests/testcth2pas.pas
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
Test with:
|
||||
./runtests --format=plain --suite=TTestCodetoolsH2Pas
|
||||
./runtests --format=plain --suite=TestCTH2PMergeHeaderFiles
|
||||
}
|
||||
unit TestCTH2Pas;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$DEFINE VerboseTestCTH2Pas}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testglobals, FileProcs, CodeToolManager,
|
||||
CodeCache, CCodeParserTool, H2PasTool;
|
||||
|
||||
type
|
||||
|
||||
{ TTestCodetoolsH2Pas }
|
||||
|
||||
TTestCodetoolsH2Pas = class(TTestCase)
|
||||
protected
|
||||
published
|
||||
procedure TestCTH2PMergeHeaderFiles;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestCodetoolsH2Pas }
|
||||
|
||||
procedure TTestCodetoolsH2Pas.TestCTH2PMergeHeaderFiles;
|
||||
var
|
||||
Header1, Header2: TCodeBuffer;
|
||||
Merger: TCHeaderFileMerger;
|
||||
Filenames: TStringList;
|
||||
Src: String;
|
||||
Header1Start: LongInt;
|
||||
Header2Start: LongInt;
|
||||
Header1End: LongInt;
|
||||
begin
|
||||
Header1:=CodeToolBoss.CreateFile('header1.h');
|
||||
Header2:=CodeToolBoss.CreateFile('header2.h');
|
||||
|
||||
Header1.Source:='// header1.h'+LineEnding
|
||||
+'#include header2.h'+LineEnding
|
||||
+'// end of header1.h';
|
||||
Header2.Source:='// header2.h';
|
||||
Merger:=TCHeaderFileMerger.Create;
|
||||
Filenames:=TStringList.Create;
|
||||
try
|
||||
Filenames.Add('header1.h');
|
||||
Filenames.Add('header2.h');
|
||||
Merger.Merge(Filenames,CodeToolBoss.SourceCache,[]);
|
||||
Src:=Merger.CombinedSource.Source;
|
||||
Header1Start:=System.Pos('// header1.h',Src);
|
||||
Header2Start:=System.Pos('// header2.h',Src);
|
||||
Header1End:=System.Pos('// end of header1.h',Src);
|
||||
//debugln(['TTestCodetoolsH2Pas.TestCTH2PMergeHeaderFiles ',Src]);
|
||||
AssertEquals('start comment header1.h',1,Header1Start);
|
||||
AssertEquals('start comment header1.h in front of header2.h',true,Header1Start<Header2Start);
|
||||
AssertEquals('start comment header2.h in front of end of header1.h',true,Header2Start<Header1End);
|
||||
finally
|
||||
Merger.Free;
|
||||
Filenames.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
AddToCodetoolsTestSuite(TTestCodetoolsH2Pas);
|
||||
|
||||
end.
|
||||
|
@ -96,9 +96,9 @@
|
||||
<UnitName Value="TestCTXMLFixFragments"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="codetoolstests\testctrangescan.pas"/>
|
||||
<Filename Value="codetoolstests\testcth2pas.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCTRangeScan"/>
|
||||
<UnitName Value="TestCTH2Pas"/>
|
||||
</Unit11>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
|
@ -24,7 +24,7 @@ uses
|
||||
Classes, consoletestrunner,
|
||||
testglobals, testunits, dom,
|
||||
{Unit needed to set the LCL version and widget set name}
|
||||
LCLVersion, InterfaceBase, Interfaces, TestCTXMLFixFragments, TestCTRangeScan;
|
||||
LCLVersion, InterfaceBase, Interfaces, TestCTXMLFixFragments, TestCTH2Pas;
|
||||
|
||||
type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user