From dae9095083e6360d7955dad6831e272f66d4752f Mon Sep 17 00:00:00 2001 From: bigchimp Date: Sat, 19 Jul 2014 15:24:24 +0000 Subject: [PATCH] fpspreadsheet: error margin seems to be needed on Windows (FPC 2.6.4+FPC trunk), not on *nix (FPC 2.6.4) in contrast to previous commit. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3340 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/tests/datetests.pas | 12 +++++++----- components/fpspreadsheet/tests/formulatests.pas | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/components/fpspreadsheet/tests/datetests.pas b/components/fpspreadsheet/tests/datetests.pas index 0a0e0061e..9a9becc7f 100644 --- a/components/fpspreadsheet/tests/datetests.pas +++ b/components/fpspreadsheet/tests/datetests.pas @@ -372,12 +372,8 @@ var ActualDateTime: TDateTime; ErrorMargin: TDateTime; //margin for error in comparison test begin - // Seems to be needed for testing with FPC 2.7.x; 2.6.4 shows more precise comparison - {$if FPC_FULLVERSION>=20701} ErrorMargin := 1E-5/(24*60*60*1000); // = 10 nsec = 1E-8 sec (1 ns fails) - {$else} - ErrorMargin:=0; - {$endif} + if Row>High(SollDates) then fail('Error in test code: array bounds overflow. Check array size is correct.'); @@ -410,8 +406,14 @@ begin if not(TestWorkSheet.ReadAsDateTime(Row, 0, ActualDateTime)) then Fail('Could not read date time value for cell '+CellNotation(TestWorkSheet,Row)); + {$ifdef mswindows} CheckEquals(SollDates[Row],ActualDateTime,ErrorMargin,'Test date/time value mismatch, ' +'cell '+CellNotation(TestWorksheet,Row)); + {$else} + // Non-windows: test without error margin + CheckEquals(SollDates[Row],ActualDateTime,'Test date/time value mismatch, ' + +'cell '+CellNotation(TestWorksheet,Row)); + {$endif} // Don't free the workbook here - it will be reused. It is destroyed at finalization. end; diff --git a/components/fpspreadsheet/tests/formulatests.pas b/components/fpspreadsheet/tests/formulatests.pas index aaffe149e..534a5d4bf 100644 --- a/components/fpspreadsheet/tests/formulatests.pas +++ b/components/fpspreadsheet/tests/formulatests.pas @@ -157,17 +157,12 @@ var hr,min,sec,msec: Word; ErrorMargin: double; begin - // Seems to be needed for testing with FPC 2.7.x; 2.6.4 shows more precise comparison - {$if FPC_FULLVERSION>=20701} ErrorMargin:=1.44E-7; //1.44E-7 for SUMSQ formula //6.0E-8 for SUM formula //4.8E-8 for MAX formula //2.4E-8 for now formula //about 1E-15 is needed for some trig functions - {$else} - ErrorMargin:=0; - {$endif} // Create test workbook MyWorkbook := TsWorkbook.Create; @@ -219,9 +214,16 @@ begin 'Test read calculated formula result mismatch, formula "' + formula + '", cell '+CellNotation(MyWorkSheet,Row,1)); atNumber: + {$ifdef mswindows} CheckEquals(expected.NumberValue, actual.NumberValue, ErrorMargin, 'Test read calculated formula result mismatch, formula "' + formula + '", cell '+CellNotation(MyWorkSheet,Row,1)); + {$else} + // Non-Windows: test without error margin + CheckEquals(expected.NumberValue, actual.NumberValue, + 'Test read calculated formula result mismatch, formula "' + formula + + '", cell '+CellNotation(MyWorkSheet,Row,1)); + {$endif} atString: CheckEquals(expected.StringValue, actual.StringValue, 'Test read calculated formula result mismatch, formula "' + formula +