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
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, //StrUtils,
|
Classes, SysUtils, TypInfo, //StrUtils,
|
||||||
fpstypes;
|
fpstypes;
|
||||||
|
|
||||||
// Exported types
|
// Exported types
|
||||||
@ -168,6 +168,8 @@ function SameFont(AFont1, AFont2: TsFont): Boolean; overload;
|
|||||||
function SameFont(AFont: TsFont; AFontName: String; AFontSize: Single;
|
function SameFont(AFont: TsFont; AFontName: String; AFontSize: Single;
|
||||||
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Boolean; overload;
|
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Boolean; overload;
|
||||||
|
|
||||||
|
function GetSetValues(const aSet: PTypeInfo; Value: Integer):string;
|
||||||
|
|
||||||
//function GetUniqueTempDir(Global: Boolean): String;
|
//function GetUniqueTempDir(Global: Boolean): String;
|
||||||
|
|
||||||
procedure AppendToStream(AStream: TStream; const AString: String); inline; overload;
|
procedure AppendToStream(AStream: TStream; const AString: String); inline; overload;
|
||||||
@ -2495,6 +2497,29 @@ begin
|
|||||||
end;
|
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
|
initialization
|
||||||
InitUTF8FormatSettings;
|
InitUTF8FormatSettings;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
unit fonttests;
|
unit fonttests;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
//{$mode objfpc}{$H+}
|
||||||
|
{$mode Delphi}{$H+}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
{ Font tests
|
{ Font tests
|
||||||
@ -71,7 +72,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
TypInfo;
|
fpsutils, TypInfo;
|
||||||
|
|
||||||
const
|
const
|
||||||
FontSheet = 'Font';
|
FontSheet = 'Font';
|
||||||
@ -243,8 +244,17 @@ begin
|
|||||||
font := MyWorksheet.ReadCellFont(MyCell);
|
font := MyWorksheet.ReadCellFont(MyCell);
|
||||||
CheckEquals(SollSizes[row], font.Size,
|
CheckEquals(SollSizes[row], font.Size,
|
||||||
'Test unsaved font size, cell ' + CellNotation(MyWorksheet,0,0));
|
'Test unsaved font size, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
{$IF FPC_FULLVERSION >= 030101}
|
||||||
expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
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,
|
CheckEquals(currValue, expectedValue,
|
||||||
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
end;
|
end;
|
||||||
@ -278,8 +288,10 @@ begin
|
|||||||
if abs(SollSizes[row] - font.Size) > 1e-6 then // safe-guard against rounding errors
|
if abs(SollSizes[row] - font.Size) > 1e-6 then // safe-guard against rounding errors
|
||||||
CheckEquals(SollSizes[row], font.Size,
|
CheckEquals(SollSizes[row], font.Size,
|
||||||
'Test saved font size, cell '+CellNotation(MyWorksheet,Row,Col));
|
'Test saved font size, cell '+CellNotation(MyWorksheet,Row,Col));
|
||||||
currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
// currValue := GetEnumName(TypeInfo(TsFontStyles), integer(font.Style));
|
||||||
expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
// expectedValue := GetEnumName(TypeInfo(TsFontStyles), integer(SollStyles[col]));
|
||||||
|
currValue := GetSetValues(TypeInfo(TsFontStyles), byte(font.Style));
|
||||||
|
expectedValue := GetSetValues(TypeInfo(TsFontStyles), byte(SollStyles[col]));
|
||||||
CheckEquals(currValue, expectedValue,
|
CheckEquals(currValue, expectedValue,
|
||||||
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
'Test unsaved font style, cell ' + CellNotation(MyWorksheet,0,0));
|
||||||
inc(counter);
|
inc(counter);
|
||||||
|
Reference in New Issue
Block a user