mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 00:40:43 +01:00
TAChart: Add TPublishedIntegerSetTest.TestAsBooleans method
git-svn-id: trunk@37419 -
This commit is contained in:
parent
71d05cc6c6
commit
e123a13fff
@ -75,6 +75,7 @@ type
|
||||
protected
|
||||
procedure SetUp; override;
|
||||
published
|
||||
procedure TestAsBooleans;
|
||||
procedure TestAsString;
|
||||
procedure TestIsSet;
|
||||
end;
|
||||
@ -404,6 +405,43 @@ begin
|
||||
FISet.Init;
|
||||
end;
|
||||
|
||||
procedure TPublishedIntegerSetTest.TestAsBooleans;
|
||||
|
||||
function BooleansToStr(const A: array of Boolean): String;
|
||||
var
|
||||
b: Boolean;
|
||||
begin
|
||||
Result := '';
|
||||
for b in A do begin
|
||||
if Result <> '' then
|
||||
Result += ',';
|
||||
Result += BoolToStr(b, 'true', 'false');
|
||||
end;
|
||||
Result := '[' + Result + ']';
|
||||
end;
|
||||
|
||||
procedure AssertBooleans(const AExpected: array of Boolean; ACount: Integer);
|
||||
var
|
||||
actual: array of Boolean;
|
||||
len: Integer;
|
||||
begin
|
||||
actual := FISet.AsBooleans(ACount);
|
||||
len := Length(actual);
|
||||
AssertTrue(
|
||||
BooleansToStr(actual) + ' = ' + BooleansToStr(AExpected),
|
||||
(len = Length(AExpected)) and
|
||||
((len = 0) or (CompareByte(actual[0], AExpected[0], len) = 0)));
|
||||
end;
|
||||
|
||||
begin
|
||||
AssertBooleans([], 0);
|
||||
FISet.AllSet := false;
|
||||
FISet.IsSet[2] := true;
|
||||
AssertBooleans([false, false, true], 3);
|
||||
FISet.AllSet := true;
|
||||
AssertBooleans([true, true, true, true], 4);
|
||||
end;
|
||||
|
||||
procedure TPublishedIntegerSetTest.TestAsString;
|
||||
begin
|
||||
AssertTrue(FISet.AllSet);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user