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

Assert.AreNotEqual not reporting actual value when test failed #18

Open
boobystu opened this issue Feb 22, 2021 · 1 comment
Open

Assert.AreNotEqual not reporting actual value when test failed #18

boobystu opened this issue Feb 22, 2021 · 1 comment

Comments

@boobystu
Copy link

When the test "Assert.AreNotEqual 1, 1" is attempted the error message contains the text
Expected: not 1
But was : Empty

This behaviour is also seen if tests Assert.AreNotEqualFloats or Assert.AreNotEqualStrings are used.

I've traced this back to EqualConstraint.Matches.
mActual is only populated when mComparer.Equals(mExpected, Actual) = False.

The fix is to always call "VariantCopyInd mActual, Actual" at the start of EqualConstraint.Matches.

Has anyone noticed this and if so do you have a different solution?

@kellyethridge
Copy link
Owner

I didn't populate the mActual field unless the test failed in an attempt to not create unnecessary copies of some kinds of variable types. Specifically strings and arrays. It's probably a completely unnecessary optimization, but it was written a long time ago and I was young :) I didn't even think about the NotConstraint causing the failure and requiring a child constraint to write a message appropriate to the situation.

It seems the only solution is the one you described and will be applied for any upcoming releases.

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

2 participants