Skip to content

Commit

Permalink
add range checks
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Nov 18, 2015
1 parent 5a34ae4 commit 919009d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions std/experimental/range/ndslice.d
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,10 @@ public:
unittest {
import std.range: iota;
auto slice = 10000.iota.sliced(10, 20, 30);

static assert(isRandomAccessRange!(typeof(slice)));
static assert(hasSlicing!(typeof(slice)));
static assert(hasLength!(typeof(slice)));

assert(slice.shape == [10, 20, 30]);
slice.popFront;
Expand Down Expand Up @@ -2366,6 +2369,22 @@ unittest
assert(t0.length!3 == 40);
}

unittest {
import std.typetuple;
import std.range: iota;
foreach(R; TypeTuple!(
int*, int[], typeof(1.iota),
double*, double[], typeof(10.0.iota),
Tuple!(double, int[string])*, Tuple!(double, int[string])[]))
foreach(n; Iota!(1, 4))
{
alias S = Slice!(n, R);
static assert(isRandomAccessRange!S);
static assert(hasSlicing!S);
static assert(hasLength!S);
}
}

unittest {
auto tensor = createSlice!int(3, 4, 8);
assert(&(tensor.back.back.back()) is &tensor[2, 3, 7]);
Expand Down

0 comments on commit 919009d

Please sign in to comment.