Delphi-Mocks presents two functions :
function CompareValue(const Left,Right : TValue): Integer;
function SameValue(const Left, Right: TValue): Boolean;
With the record helper for TValue you can also do TValue.Equals(TValue);
Licensed under Apache terms and under permission by Stefan Glienke.
Here is the original source by Stefan : delphisorcery.
If you need to extend the functionality for variants, add:
function TValueHelper.IsVariant: Boolean;
begin
Result := TypeInfo = System.TypeInfo(Variant);
end;
and insert
if Left.IsVariant and Right.IsVariant then
begin
Result := Left.AsVariant = Right.AsVariant;
end else
after the isString comparison in the SameValue
function.