View (unittests)

- Added more tests for `opSlice(size_t, size_t)`
This commit is contained in:
Tristan B. Velloza Kildaire 2024-05-02 09:35:41 +02:00
parent 515d85eae0
commit 6372f2d8c7
1 changed files with 31 additions and 0 deletions

View File

@ -1012,4 +1012,35 @@ unittest
view ~= 5;
assert(view[0..5] == [1,2,3,4,5]);
// test: start <= end invariant broken
try
{
auto j = view[1..0];
assert(false);
}
catch(RangeError e)
{
}
// test: end out of bounds
try
{
auto j = view[1..view.length+1];
assert(false);
}
catch(RangeError e)
{
}
int[] d = [1,2,3];
writeln("according to dlang: ", d[1..2]);
writeln("test lekker: ", view[1..2]);
assert(view[1..2] == [2]);
writeln("test lekker: ", view[1..1]);
assert(view[1..1] == []);
}