Skip to content

Commit

Permalink
Fix Issue 15918
Browse files Browse the repository at this point in the history
  • Loading branch information
nordlow committed May 24, 2016
1 parent 35b92c6 commit 54f0597
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions std/algorithm/searching.d
Expand Up @@ -2563,6 +2563,10 @@ if (isForwardRange!R1 && isForwardRange!R2)
{
asTuple = typeof(asTuple)(pre, separator, post);
}
void opAssign(typeof(asTuple) rhs)
{
asTuple = rhs;
}
Tuple!(S1, S1, S2) asTuple;
bool opCast(T : bool)()
{
Expand Down Expand Up @@ -2623,6 +2627,10 @@ if (isForwardRange!R1 && isForwardRange!R2)
{
asTuple = typeof(asTuple)(pre, post);
}
void opAssign(typeof(asTuple) rhs)
{
asTuple = rhs;
}
Tuple!(S1, S2) asTuple;
bool opCast(T : bool)()
{
Expand Down Expand Up @@ -2679,6 +2687,10 @@ if (isForwardRange!R1 && isForwardRange!R2)
{
asTuple = typeof(asTuple)(pre, post);
}
void opAssign(typeof(asTuple) rhs)
{
asTuple = rhs;
}
Tuple!(S1, S2) asTuple;
bool opCast(T : bool)()
{
Expand Down Expand Up @@ -2733,7 +2745,7 @@ if (isForwardRange!R1 && isForwardRange!R2)
}

///
@safe unittest
@safe pure nothrow unittest
{
auto a = "Carl Sagan Memorial Station";
auto r = findSplit(a, "Velikovsky");
Expand All @@ -2758,7 +2770,7 @@ if (isForwardRange!R1 && isForwardRange!R2)
assert(r2[1] == " Memorial Station");
}

@safe unittest
@safe pure nothrow unittest
{
auto a = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
auto r = findSplit(a, [9, 1]);
Expand Down Expand Up @@ -2791,7 +2803,7 @@ if (isForwardRange!R1 && isForwardRange!R2)
assert(r2[1] == a[4 .. $]);
}

@safe unittest
@safe pure nothrow unittest
{
import std.algorithm.comparison : equal;
import std.algorithm.iteration : filter;
Expand Down Expand Up @@ -2828,6 +2840,37 @@ if (isForwardRange!R1 && isForwardRange!R2)
assert(equal(r2[1], a[4 .. $]));
}

@safe pure nothrow @nogc unittest
{
auto str = "sep,one,sep,two";

auto split = str.findSplitAfter(",");
assert(split[0] == "sep,");

split = split[1].findSplitAfter(",");
assert(split[0] == "one,");

split = split[1].findSplitBefore(",");
assert(split[0] == "sep");
}

@safe pure nothrow @nogc unittest
{
auto str = "sep,one,sep,two";

auto split = str.findSplitBefore(",two");
assert(split[0] == "sep,one,sep");
assert(split[1] == ",two");

split = split[0].findSplitBefore(",sep");
assert(split[0] == "sep,one");
assert(split[1] == ",sep");

split = split[0].findSplitAfter(",");
assert(split[0] == "sep,");
assert(split[1] == "one");
}

// minCount
/**
Expand Down

0 comments on commit 54f0597

Please sign in to comment.