Android32 with incorrect TestCase parameters
viniciusfbb opened this issue · 4 comments
DUnitX is not calling the test with the correct TestCase parameters on Android 32 bits, when there are many Singles or Doubles in the parameters. I made a small project reproducing the problem (download the full project here: DUnitXBug.zip). Here's the code:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Math.Vectors,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo,
DUnitX.TestFramework;
type
[TestFixture]
TT1 = class
public
[TestCase('1', 'str1-value,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,str2-value')]
procedure Test(const AStr1: string; const F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20: Single; const AStr2: string);
end;
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
LRunner: ITestRunner;
LResults: IRunResults;
LTestResult: ITestResult;
begin
LRunner := TDUnitX.CreateRunner;
LRunner.UseRTTI := True;
LRunner.FailsOnNoAsserts := False;
LResults := LRunner.Execute;
// Show the results in a TMemo
Memo1.Lines.Text := LResults.ToString;
for LTestResult in LResults.GetAllTestResults do
Memo1.Lines.Add(LTestResult.Message);
end;
{ TT1 }
procedure TT1.Test(const AStr1: string; const F1, F2, F3, F4, F5, F6, F7, F8,
F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20: Single;
const AStr2: string);
begin
Assert.AreEqual('str1-value', AStr1);
Assert.AreEqual(1, F1, TEpsilon.Position);
Assert.AreEqual(2, F2, TEpsilon.Position);
Assert.AreEqual(3, F3, TEpsilon.Position);
Assert.AreEqual(4, F4, TEpsilon.Position);
Assert.AreEqual(5, F5, TEpsilon.Position);
Assert.AreEqual(6, F6, TEpsilon.Position);
Assert.AreEqual(7, F7, TEpsilon.Position);
Assert.AreEqual(8, F8, TEpsilon.Position);
Assert.AreEqual(9, F9, TEpsilon.Position);
Assert.AreEqual(10, F10, TEpsilon.Position);
Assert.AreEqual(11, F11, TEpsilon.Position);
Assert.AreEqual(12, F12, TEpsilon.Position);
Assert.AreEqual(13, F13, TEpsilon.Position);
Assert.AreEqual(14, F14, TEpsilon.Position);
Assert.AreEqual(15, F15, TEpsilon.Position);
Assert.AreEqual(16, F16, TEpsilon.Position);
Assert.AreEqual(17, F17, TEpsilon.Position);
Assert.AreEqual(18, F18, TEpsilon.Position);
Assert.AreEqual(19, F19, TEpsilon.Position);
Assert.AreEqual(20, F20, TEpsilon.Position);
Assert.AreEqual('str2-value', AStr2);
end;
initialization
TDUnitX.RegisterTestFixture(TT1);
end.
The problem occurs both in DUnitX from Embarcadero and in DUnitX from github. I didn't get to debug it but it could be a problem with the RTTI.
I don't so mobile dev so I'm not setup to test this, but my guess is that the wrong AreEqual overload is being called since there isn't an overload with Single parameters. Happy to accept a PR for this (assuming it doesn't break other platforms).
I don't so mobile dev so I'm not setup to test this, but my guess is that the wrong AreEqual overload is being called since there isn't an overload with Single parameters.
No, it’s not related to AreEqual function, the value of the last string parameter is also wrong.
Ok, but that doesn't alter the fact that I am not able to test this. Did you try stepping into the dunitx code to see where the bug is? You will need to add DUNITXDEBUG to your project defines to enable debug info on the dunitx code.