Skip to content

Introduce assertions for DateTime#382

Merged
vincentparrett merged 3 commits intoVSoftTechnologies:masterfrom
luebbe:master
Apr 13, 2026
Merged

Introduce assertions for DateTime#382
vincentparrett merged 3 commits intoVSoftTechnologies:masterfrom
luebbe:master

Conversation

@luebbe
Copy link
Copy Markdown
Contributor

@luebbe luebbe commented Mar 27, 2026

As always, a PR out of personal need :)

Since Assert.AreEqual can't really distinguish between date/time values and floats and Assert.IsTrue(SameDate(...)) doesn't really help to point out the differences, I introduced assertions for date/time values.

DUnitX' own tests deliver failing tests on German locale, because TValue.From fails to parse the English dates in the test cases (All dates convert to 30.12.1899). This is why I can show you some nice before/after screenshots here.

Before (using Assert.IsTrue):

DUnitX-before

After (using the new assertions):

DUnitX-after

You can provoke failures on Englisch locale if you set expectedDate and expectedTime in DUnitX.Test.Utils to something else.

90% of the changes in Tests/DUnitX.Tests.Utils.pas are caused by tabs being converted to spaces when the file was saved.

Maybe we need an IFDEF for XE* Versions. I don't know when the Same(Date/Time) functions where introduced. The new assertions should at least work from Delphi 10 onwards.

@vincentparrett
Copy link
Copy Markdown
Member

Thanks, this looks good - I wasn't able to check D2010 & XE as I don't have them installed, but SameDate appears in XE2 (the earliest version I have installed). Not too worried, we can IFDEF for XE or earlier for now until we know for sure.

@vincentparrett
Copy link
Copy Markdown
Member

Hi Luebbe

Can you merge master into your branch and fix the conflicts and I will merge the PR. We can deal with 2010/XE if someone has a problem. Gemini tells me SameDate was added in D6 but who knows if that is correct.

@vincentparrett vincentparrett merged commit b8336b3 into VSoftTechnologies:master Apr 13, 2026
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

Successfully merging this pull request may close these issues.

2 participants