VSoftTechnologies/DUnitX

TestCaseAttribute does not work with parameters of type UInt64 and values > High(Int64)

Closed this issue · 0 comments

The following example will deliver a value of 0 for parameter Value:

    [TestCaseAttribute('UInt64 18446744073709551615', '18446744073709551615')]
    procedure TestCase(Value: UInt64);

The problem is the same for all value > High(Int64).

The reason is that the converter method is using StrToInt64Def.

function ConvStr2Ord(const ASource: TValue; ATarget: PTypeInfo; out AResult: TValue): Boolean;
begin
  AResult := TValue.FromOrdinal(ATarget, StrToInt64Def(ASource.AsString, 0));
  Result := True;
end;

The following change is suggested:

function ConvStr2Ord(const ASource: TValue; ATarget: PTypeInfo; out AResult: TValue): Boolean;
begin
  if ATarget = System.TypeInfo(UInt64) then
    AResult := TValue.FromOrdinal(ATarget, StrToUInt64Def(ASource.AsString, 0))
  else
    AResult := TValue.FromOrdinal(ATarget, StrToInt64Def(ASource.AsString, 0));
  Result := True;
end;