[Issue 4653] More unit test functions should be added - like assertEqual() and assertNotEqual()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 16 14:39:48 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4653



--- Comment #3 from Jonathan M Davis <jmdavisProg at gmail.com> 2010-08-16 14:39:44 PDT ---
It's not necessarily a bad idea, but it doesn't work as well with the error
messages - and the improved error messages is the main reason for having these
sort of functions over normal assert. With a generic predicate, you'd have to
print out both the actual and expected every time when some functions would do
just fine with just the actual, while other functions might work better as not
being treated entirely as a boolean result. For instance, for assertLessThan()
could choose to use opCmp if available rather than < and then print out the
actual result of opCmp if it weren't < 0 rather that just printing the two
values and saying it failed. If you're assuming a generic predicate which takes
two values and returns a bool, then you can't do that.

So, I do think that having a unit testing function which takes a generic
predicate which takes two values and returns bool could be useful, I don't
think that it's ultimately as useful because the error messages aren't as good.
And honestly, the error messages are the reason that I think that these sort of
functions are worth adding to Phobos instead of just using normal assert.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list