unittesting generic functions
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 14 22:32:09 PDT 2014
On 8/14/14, 7:46 PM, H. S. Teoh via Digitalmars-d wrote:
> On Thu, Aug 14, 2014 at 05:49:39PM -0700, Andrei Alexandrescu via Digitalmars-d wrote:
>> On 8/14/14, 3:34 PM, H. S. Teoh via Digitalmars-d wrote:
>>> How does this relate to writing generic unittests? Since the incoming
>>> types are generic, you can't assume anything about them beyond what
>>> the function itself already assumes, so how would the unittest test
>>> anything beyond what the function already does?
>>
>> Check the workings of the function via an alternate algorithm for
>> example. There's plenty of examples, including unittests inside a
>> parameterized struct/class test methods within that class.
>
> Can you give a concrete example?
For all integrals converting some value to a string and back should
yield the same value.
Accelerated searches in any sorted ranges should provide the same result
as linear searches.
Sorting should provide sorted results.
...
Andrei
More information about the Digitalmars-d
mailing list