From: Thomas M. <tw...@us...> - 2006-05-27 18:01:38
|
Update of /cvsroot/gexperts/gexperts/unstable/Src/Formatter/unittests In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv32143/unstable/Src/Formatter/unittests Modified Files: DelForExTestFiles.pas DelForExTestOldNew.pas Log Message: adapted unit tests to new formatter interface Index: DelForExTestOldNew.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/unittests/DelForExTestOldNew.pas,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- DelForExTestOldNew.pas 9 Dec 2005 16:20:35 -0000 1.22 +++ DelForExTestOldNew.pas 27 May 2006 18:01:28 -0000 1.23 @@ -132,11 +132,18 @@ end; procedure TTestCompareOldNew.CompareOldNew(const _Input, _Expected, _Description: string); +var + st: TStringList; begin - FNewFormatter.Sourcecode := _Input; - Check(FNewFormatter.Execute, 'Error in formatter engine'); - FLastActual := FNewFormatter.Sourcecode; - CheckEquals(_Expected, FLastActual, _Description + ' had unexpected differences') + st := TStringList.Create; + try + st.Text := _Input; + Check(FNewFormatter.Execute(st), 'Error in formatter engine'); + FLastActual := st.Text; + CheckEquals(_Expected, FLastActual, _Description + ' had unexpected differences') + finally + st.Free; + end; end; procedure TTestCompareOldNew.testJustOpeningComment; Index: DelForExTestFiles.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/unittests/DelForExTestFiles.pas,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- DelForExTestFiles.pas 1 May 2006 12:12:41 -0000 1.30 +++ DelForExTestFiles.pas 27 May 2006 18:01:28 -0000 1.31 @@ -127,33 +127,28 @@ Filename: string; InFile: string; ExpectedFile: string; - InString: string; - ExpectedStr: string; - OutString: string; + ExpectedText: TStringList; st: TStringList; begin Filename := 'testfile_' + _Filename + '.pas'; InFile := 'unittests\testcases\input\' + Filename; ExpectedFile := 'unittests\testcases\expected-' + GetResultDir + '\' + Filename; + ExpectedText := nil; st := TStringList.Create; try st.LoadFromFile(InFile); - InString := st.Text; - st.Clear; - st.LoadFromFile(ExpectedFile); - ExpectedStr := st.Text; - FFormatter.Sourcecode := InString; - Check(FFormatter.Execute, 'error in formatter'); - OutString := FFormatter.Sourcecode; + ExpectedText := TStringList.Create; + ExpectedText.LoadFromFile(ExpectedFile); + FFormatter.Execute(st); try - CheckEquals(ExpectedStr, OutString, 'error in output'); + CheckEquals(ExpectedText.Text, st.Text, 'error in output'); except - st.Text := OutString; st.SaveToFile('unittests\testcases\output-' + GetResultDir + '\' + Filename); if not _AllowFaiure then raise; end; finally + ExpectedText.Free; st.Free; end; end; |