Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer compare always true #333

Open
monkeysfoot opened this issue Aug 27, 2023 · 1 comment
Open

Integer compare always true #333

monkeysfoot opened this issue Aug 27, 2023 · 1 comment

Comments

@monkeysfoot
Copy link

I have a test defined like so:

[Test]
 [TestCase('TestSetAsInteger 001.', '0')]
 [TestCase('TestSetAsInteger 002.', '666')]
 procedure TestSetAsInteger(IntVal : integer);

And Implemented like so:

procedure TTestKeyValueList.TestSetAsInteger(IntVal: integer);
begin
  FKVL.AsInteger['testkey'] := IntVal;
  Assert.AreEqual(IntVal, FKVL.AsInteger['testkey']);
end;

The methods in FKVL are stubs, so they should fail. Problem is, they always pass.

Now, If I change the test implementation to:

procedure TTestKeyValueList.TestSetAsInteger(IntVal: integer);
begin
  FKVL.AsInteger['testkey'] := IntVal;
  Sleep(1);  //This can be anything really, I can call FKVL.Count or other some such
  Assert.AreEqual(IntVal, FKVL.AsInteger['testkey']);
end;

The test now works as intended. Weird.

@monkeysfoot
Copy link
Author

There is a good explanation of why this happened on the question about this I posted on stackoverflow.

https://stackoverflow.com/questions/76988385/dunitx-integer-test-always-true/76991051#76991051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant