tests: started codetools completeblock test

git-svn-id: trunk@21337 -
This commit is contained in:
mattias 2009-08-19 21:49:48 +00:00
parent 4a05e3f8e0
commit f63f57fda7
2 changed files with 55 additions and 0 deletions

1
.gitattributes vendored
View File

@ -4638,6 +4638,7 @@ test/bugs/bug8432.pas svneol=native#text/plain
test/bugs/testfileproc.pas svneol=native#text/plain
test/bugs/testfileutil.pas svneol=native#text/plain
test/bugtestcase.pas svneol=native#text/plain
test/codetoolstests/testcompleteblock.pas svneol=native#text/plain
test/hello.ahk svneol=native#text/plain
test/lcltests/testpen.pas svneol=native#text/plain
test/lcltests/testunicode.pas svneol=native#text/plain

View File

@ -0,0 +1,54 @@
unit TestCompleteBlock;
{$mode objfpc}{$H+}
interface
uses
fpcunit, Classes, SysUtils;
type
{ TCodeBlocksTest }
TCodeBlocksTest = class(TTestCase)
protected
function CompareComplete(const InputDefines, ResultFile: String): Boolean;
published
procedure TestCompleteBlocks;
end;
implementation
{ TCodeBlocksTest }
function TCodeBlocksTest.CompareComplete(const InputFile, InputDefines, ResultFile: String): Boolean;
var
st : TStringList;
rs : TStringList;
function StripSpaceChars(const s: string): String;
begin
// removes all [#10,#13,#9, #32] chars, giving a line: "beginwriteln('helloworld');end."
Result:=s;
for i:=length(Result) downto 1 do
if Result[i] in [#10,#13,#9,' '] then
System.Delete(Result,i,1);
end;
begin
// ToDo: fix path to completeblock, InputFile nd ResultFile
st := GetProcessOutput('completeblock '+InputFile+' '+inputdefines); // reads all output from blockcompleted file
// remove debugging output and take only the new source
while (st.Count>0) and (st[0]<>'{%MainUnit unit1.pas}') do st.Delete(0);
// reads the correct result file
rs.LoadFromFile(resultfile);
// check result
AssertEquals(StripSpaceChars(st.text), StripSpaceChars(rs.text)); // compares resulting strings
end;
procedure TCodeBlocksTest.TestCompleteBlocks;
begin
CompareComplete('ifbeginelse1.inc','6 28 ifbeginelse fpcunit', 'ifbeginelse1.result');
end;
end.