Add findSplitBefore example with an element using only()

Also remove typo.
This commit is contained in:
Nick Treleaven 2016-10-06 12:05:03 +01:00
parent 08c587ead2
commit ae6a8031cf

View file

@ -2809,7 +2809,7 @@ if (isForwardRange!R1 && isForwardRange!R2)
assert(r[2] == "Sagan Memorial Station");
auto r1 = findSplitBefore(a, "Sagan");
assert(r1);
assert(r1[0] == "Carl ", r1[0]);
assert(r1[0] == "Carl ");
assert(r1[1] == "Sagan Memorial Station");
auto r2 = findSplitAfter(a, "Sagan");
assert(r2);
@ -2817,6 +2817,13 @@ if (isForwardRange!R1 && isForwardRange!R2)
assert(r2[1] == " Memorial Station");
}
/// Use $(REF only, std,range) to find single elements:
@safe pure nothrow unittest
{
import std.range : only;
assert([1, 2, 3, 4].findSplitBefore(only(3))[0] == [1, 2]);
}
@safe pure nothrow unittest
{
import std.range.primitives : empty;