I believe that the methods TValueHelper.Equals and TValueHelper.Compare do not work correctly if they are used to compare values of the Currency type.

Issue #357 resolved
Aleksandr Sysoev created an issue

To demonstrate the errors, you can add the following test cases to the TTestValueHelper unit test:

procedure TTestValueHelper.Test_CurrencyToCurrency_Equals;
begin
  fSUT := Currency(12345678901234.56);
  fValue := Currency(12345678901234.5606);
  DoCheckEquals(False);
end;

procedure TTestValueHelper.Test_CurrencyToCurrency_Compare;
begin
  fSUT := Currency(12345678901234.56);
  fValue := Currency(12345678901234.5606);
  DoCheckCompare(-1);
end;

Without changes in Source\Base\Spring.pas, both tests generate an error. This is wrong.
I found these errors when working under Delphi 10.3, but I believe that they will occur on other versions.

To solve this problem, I suggest making changes to functions CompareValue and EqualsFloat2Float в модуле Source\Base\Spring.pas.

I do not have the permission to create a pull request, so I attach the files with the changes I made.

Comments (2)

  1. Log in to comment