Feasible Idea?: Range Tester

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Thu Mar 21 10:08:58 PDT 2013


Suppose you create a range: struct MyRange{...}

Now you have to unittest it. And there's a lot of ways a range
implementation can go wrong. There's a fair amount of things to test.
And they all, ideally, need to be done for *every* range type created.

But, ranges are all supposed to conform to a standard interface with
standardized semantics. So can't most of this testing be generalized
into a generic InputRangeTester, RandomAccessRageTester, etc? All you'd
do is feed it an array of elements to test with, and, in theory, it
should be able to unittest the range's semantics for conformance.

Obviously it couldn't guarantee 100% conformance, because no unittest
can do that, but it seems reasonable that it could be just as good as a
well-designed set of hand-written tests.

I think this would be an enormously useful thing to have in Phobos. Can
any Phobos/range gurus say fur sure how feasible this is? Does Phobos
perhaps already do something similar internally that could just be
generalized?

(This message has been brought to you by three random access ranges I
just created but really, really don't feel like unittesting ;) )



More information about the Digitalmars-d mailing list