From 4625cb9c16b28c32cfada6846868396721e299a1 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 26 Oct 2006 13:26:44 +0000 Subject: [PATCH] + Removed helper function. Indentation should not be a global variable git-svn-id: trunk@5025 - --- fcl/fpcunit/testreport.pp | 41 +++++++++++++-------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/fcl/fpcunit/testreport.pp b/fcl/fpcunit/testreport.pp index 42ef768b8d..6216e2afc9 100644 --- a/fcl/fpcunit/testreport.pp +++ b/fcl/fpcunit/testreport.pp @@ -53,6 +53,7 @@ type procedure EndTest(ATest: TTest); end;} +function TestSuiteAsXML(aSuite:TTestSuite; Indent : Integer): string; function TestSuiteAsXML(aSuite: TTestSuite): string; function TestSuiteAsLatex(aSuite:TTestSuite): string; function TestSuiteAsPlain(aSuite:TTestSuite): string; @@ -64,23 +65,6 @@ function TestResultAsPlain(aTestResult: TTestResult): string; implementation -var - uLevel: integer; // indentation counter - - -// Helper function: Return a string of spaces pIntLen long -function trSpace(pIntLen: integer): string; -var - i: integer; - sString: string; -begin - sString := ''; - for i := 1 to pIntLen do - sString := sString + ' '; - Result := sString; -end; - - {TXMLResultsWriter} procedure TXMLResultsWriter.WriteHeader; begin @@ -156,21 +140,27 @@ begin writeln; end; - function TestSuiteAsXML(aSuite:TTestSuite): string; + +begin + Result:=TestSuiteAsXML(ASuite,0); +end; + +function TestSuiteAsXML(aSuite:TTestSuite; Indent : Integer): string; + var i: integer; begin - Result := trSpace(uLevel) + '' + System.sLineBreak; - Inc(uLevel, 2); + Result := StringOfChar(' ',Indent) + '' + System.sLineBreak; + Inc(Indent, 2); for i := 0 to aSuite.Tests.Count - 1 do if TTest(aSuite.Tests.Items[i]) is TTestSuite then - Result := Result + TestSuiteAsXML(TTestSuite(aSuite.Tests.Items[i])) + Result := Result + TestSuiteAsXML(TTestSuite(aSuite.Tests.Items[i]),Indent) else if TTest(aSuite.Tests.Items[i]) is TTestCase then - Result := Result + trSpace(uLevel) + '' + TTestcase(aSuite.Tests.Items[i]).TestName + '' + System.sLineBreak; - Dec(uLevel, 2); - Result := Result + trSpace(uLevel) + '' + System.sLineBreak; + Result := Result + StringOfChar(' ',Indent) + '' + TTestcase(aSuite.Tests.Items[i]).TestName + '' + System.sLineBreak; + Dec(Indent, 2); + Result := Result + StringOfChar(' ',Indent) + '' + System.sLineBreak; end; @@ -336,7 +326,4 @@ begin end; -initialization - uLevel := 0; - end.