Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Colvin committed Jun 17, 2020
1 parent a6da2af commit 15bb8ed
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions std/algorithm/setops.d
Expand Up @@ -554,6 +554,40 @@ pure @safe nothrow @nogc unittest
foreach (pair; cartesianProduct(seq, seq)) {}
}

unittest
{
import std.algorithm.comparison : equal;
import std.typecons : tuple;

static struct SystemRange
{
int[] data;

int front() @system @property
{
return data[0];
}

bool empty() @system @property
{
return data.length == 0;
}

void popFront() @system
{
data = data[1 .. $];
}

SystemRange save() @system
{
return this;
}
}

assert(SystemRange([1, 2]).cartesianProduct(SystemRange([3, 4]))
.equal([tuple(1, 3), tuple(1, 4), tuple(2, 3), tuple(2, 4)]));
}

// largestPartialIntersection
/**
Given a range of sorted $(REF_ALTTEXT forward ranges, isForwardRange, std,range,primitives)
Expand Down

0 comments on commit 15bb8ed

Please sign in to comment.