What are the best std algo for testing a range implementation ?

BicMedium via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 27 09:49:40 PDT 2014


On Tuesday, 27 May 2014 at 14:05:56 UTC, monarch_dodra wrote:
> On Tuesday, 27 May 2014 at 12:18:15 UTC, BicMedium wrote:
>> I mean that those tests are just like testing an interface...).
>
> If your interface isn't complete, than it is irrelevant what 
> your implementations are, since the algorithms can't use your 
> ranges anyways.

We agree on this point. The template constrains for isInputRange 
or isOutputRange just check, at compile-time, if the methods 
matchings to the prototypes defined in std.ranges (or in 
std.container empty, popFront, etc...) are implemented.

But there could be a templated-unittest for those kind of 
things...Ranges are relatively straightforward in to use, but 
when you want to implement one, it's another thing...So it's just 
about indexes ? And a kind of State machine for indexes 
(push/pop) ?
I hardly get how to make my easy containers range-aware. but I 
want to, because of std.algo.


More information about the Digitalmars-d-learn mailing list