You've already forked lazarus-ccr
fpspreadsheet: Fix incorrect usage of GetEnumName in test suite.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4381 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -18,7 +18,7 @@ unit fpsutils;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, //StrUtils,
|
||||
Classes, SysUtils, TypInfo, //StrUtils,
|
||||
fpstypes;
|
||||
|
||||
// Exported types
|
||||
@ -168,6 +168,8 @@ function SameFont(AFont1, AFont2: TsFont): Boolean; overload;
|
||||
function SameFont(AFont: TsFont; AFontName: String; AFontSize: Single;
|
||||
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Boolean; overload;
|
||||
|
||||
function GetSetValues(const aSet: PTypeInfo; Value: Integer):string;
|
||||
|
||||
//function GetUniqueTempDir(Global: Boolean): String;
|
||||
|
||||
procedure AppendToStream(AStream: TStream; const AString: String); inline; overload;
|
||||
@ -2495,6 +2497,29 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{@@ Returns a readable string containing the names of the elements contained in
|
||||
a set. For example, call like
|
||||
s := GetSetValue(TypeInfo(TsFontStyles, Integer(font.style));
|
||||
-------------------------------------------------------------------------------}
|
||||
function GetSetValues(const aSet:PTypeInfo; Value: Integer):string;
|
||||
var
|
||||
vData1 : PTypeData;
|
||||
vData2 : PTypeData;
|
||||
vCntr : Integer;
|
||||
v: Integer;
|
||||
begin
|
||||
Result := '';
|
||||
if aSet^.Kind = tkSet then begin
|
||||
vData1 := GetTypeData(aSet);
|
||||
vData2 := GetTypeData(vData1^.CompType);
|
||||
for vCntr := vData2^.MinValue to vData2^.MaxValue do
|
||||
if (Value shr vCntr) and 1 <> 0 then
|
||||
Result := Result+ GetEnumName(vData1^.CompType,vCntr)+',';
|
||||
if Result <> '' then Delete(Result, Length(Result), 1);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
InitUTF8FormatSettings;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
unit fonttests;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
//{$mode objfpc}{$H+}
|
||||
{$mode Delphi}{$H+}
|
||||
|
||||
interface
|
||||
{ Font tests
|
||||
@ -71,7 +72,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
TypInfo;
|
||||
fpsutils, TypInfo;
|
||||
|
||||
const
|
||||
FontSheet = 'Font';
|
||||
@ -243,8 +244,17 @@ begin
|
||||
font := MyWorksheet.ReadCellFont(MyCell);
|
||||
CheckEquals(SollSizes[row], font.Size,
|
||||
'Test unsaved font size, cell ' + CellNotation(MyWorksheet,0,0));
|
||||
currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
||||
expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||
{$IF FPC_FULLVERSION >= 030101}
|
||||
currValue := GetEnumName(TypeInfo(TsFontStyles), byte(font.Style)); // wp: 2.6.4--> integer, 3.1.1 --> byte!
|
||||
expectedValue := GetEnumName(TypeInfo(TsFontStyles), byte(SollStyles[col]));
|
||||
currValue := GetSetValues(TypeInfo(TsFontStyles), byte(font.Style));
|
||||
expectedValue := GetSetValues(TypeInfo(TsFontStyles), byte(SollStyles[col]));
|
||||
{$ELSE}
|
||||
// currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style)); // wp: 2.6.4--> integer, 3.1.1 --> byte!
|
||||
// expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||
currValue := GetSetValues(TypeInfo(TsFontStyles), integer(font.Style));
|
||||
expectedValue := GetSetValues(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||
{$ENDIF}
|
||||
CheckEquals(currValue, expectedValue,
|
||||
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
||||
end;
|
||||
@ -278,8 +288,10 @@ begin
|
||||
if abs(SollSizes[row] - font.Size) > 1e-6 then // safe-guard against rounding errors
|
||||
CheckEquals(SollSizes[row], font.Size,
|
||||
'Test saved font size, cell '+CellNotation(MyWorksheet,Row,Col));
|
||||
currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
||||
expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||
// currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
||||
// expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||
currValue := GetSetValues(TypeInfo(TsFontStyles), byte(font.Style));
|
||||
expectedValue := GetSetValues(TypeInfo(TsFontStyles), byte(SollStyles[col]));
|
||||
CheckEquals(currValue, expectedValue,
|
||||
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
||||
inc(counter);
|
||||
|
Reference in New Issue
Block a user