From 1541796ecdc8a9c90feee436d7af0a50013acfc8 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 25 Apr 2014 09:02:10 +0000 Subject: [PATCH] fpspreadsheet: Fix font unit test for bif2 (Excel2 allows only 4 fonts per file) --> pass git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2965 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/tests/fonttests.pas | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/components/fpspreadsheet/tests/fonttests.pas b/components/fpspreadsheet/tests/fonttests.pas index b9579bf75..413fd5acd 100644 --- a/components/fpspreadsheet/tests/fonttests.pas +++ b/components/fpspreadsheet/tests/fonttests.pas @@ -34,22 +34,13 @@ type procedure SetUp; override; procedure TearDown; override; procedure TestWriteReadFont(AFormat: TsSpreadsheetFormat; AFontName: String); + published - { // BIFF2 test cases procedure TestWriteReadFontBIFF2_Arial; procedure TestWriteReadFontBIFF2_TimesNewRoman; procedure TestWriteReadFontBIFF2_CourierNew; - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - Currently the BIFF2 tests fail because of a font size mismatch at size 11. - Outside the test suite, however, this error is not reproduced, - and also not when the conflicting case is used in the SollValues alone. - - STRANGE... - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - } - // BIFF8 test cases procedure TestWriteReadFontBIFF8_Arial; procedure TestWriteReadFontBIFF8_TimesNewRoman; @@ -130,6 +121,7 @@ var font: TsFont; currValue: String; expectedValue: String; + counter: Integer; begin TempFile:=GetTempFileName; {// Not needed: use workbook.writetofile with overwrite=true @@ -170,8 +162,11 @@ begin MyWorksheet := GetWorksheetByName(MyWorkBook, FontSheet); if MyWorksheet=nil then fail('Error in test code. Failed to get named worksheet'); + counter := 0; for row := 0 to MyWorksheet.GetLastRowNumber do for col := 0 to MyWorksheet.GetLastColNumber do begin + if (AFormat = sfExcel2) and (counter = 4) then + break; // Excel 2 allows only 4 fonts MyCell := MyWorksheet.FindCell(row, col); if MyCell = nil then fail('Error in test code. Failed to get cell.'); @@ -183,12 +178,13 @@ begin expectedValue := GetEnumName(TypeInfo(TsFontStyles), byte(SollStyles[col])); CheckEquals(currValue, expectedValue, 'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0)); + inc(counter); end; MyWorkbook.Free; DeleteFile(TempFile); end; - (* + procedure TSpreadWriteReadFontTests.TestWriteReadFontBIFF2_Arial; begin TestWriteReadFont(sfExcel2, 'Arial'); @@ -203,7 +199,6 @@ procedure TSpreadWriteReadFontTests.TestWriteReadFontBIFF2_CourierNew; begin TestWriteReadFont(sfExcel2, 'CourierNew'); end; -*) procedure TSpreadWriteReadFontTests.TestWriteReadFontBIFF8_Arial; begin