What are the best std algo for testing a range implementation ?
Let's say I have a set of containers, using a D-unfriendly-semantic. They rather use a kind of ADA vocabulary (according to https://en.wikipedia.org/wiki/Deque). I want to make them range-aware. If the input/output ranges are easy to implement(so it's just reading/writing an element, keeping an index for the writer and another for the reader, and reseting it, isn't it ? So if (isInputRange!MyCont isOutputRange!MyCont) then it's a Deque, right ?). The bidirectionnal ranges or the forward ranges become more difficult to interpret with the idioms I use(Insert,Add,Remove)...Is this a kind of 3rd plane (time: return to previous state, make a backup: copy/roll-back - undo/redo ?) Could you recommend me the algos from std.algo to test efficiently my implementations ? (example, if you want to be sure that the input ranges work then you'd use this...if you want to be sure that output ranges work then you'd use that ...Some kind of reference unit tests ?). At the present time, each time I try one I get rejected by the template constraints...
Re: What are the best std algo for testing a range implementation ?
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.