Review: A new stab at a potential std.unittests [Update]

Jonathan M Davis jmdavisProg at gmx.com
Fri Nov 26 00:10:51 PST 2010


Most recent code: http://is.gd/hO8HP

Per the suggestions in this thread, I changed the string mixin templates to 
functions using lazy. I also added assertOpBinary and made assertOpOpAssign() 
call opOpAssign() directly. Finally, I made assertEqual() and assertNotEqual() 
templatized on a predicate (like std.algorithm.equal()) as suggested.

I did not add an assertPred(), because on further reflection, it didn't really 
make sense. Aside from the issue of unary vs binary predicates (which could be 
solved with assertUniPred() and assertBiPred()), what a predicate does varies so 
much from function to function, that testing one generically just doesn't make 
sense. For instance, find() is looking for equality whereas sort() is looking for 
a comparison. You could test that all elements in a range return true for a 
predicate like you might want with find(), but doing the same thing with sort()'s 
predicate makes no sense at all. So, I didn't add assertPred() or anything 
similar.

Any more feedback on my potential std.unittests, or is looking good overall? I 
definitely think that it's better than when I first posted it, so the feedback 
thus far has definitely been helpful, and I do find these functions extremely 
useful in my own code.

- Jonathan M Davis


P.S. My most recent update for std.datetime does include the most recent version 
of unittests.d, so if you want to see them in more large scale use, you can look 
there.


More information about the Digitalmars-d mailing list