mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 22:50:38 +03:00
Coverage for minCount
This commit is contained in:
parent
e6e323175d
commit
9d33fb078d
1 changed files with 12 additions and 7 deletions
|
@ -7046,14 +7046,14 @@ minCount(alias pred = "a < b", Range)(Range range)
|
||||||
}
|
}
|
||||||
else static if (hasLvalueElements!Range)
|
else static if (hasLvalueElements!Range)
|
||||||
{
|
{
|
||||||
T* p = &(range.front());
|
T* p = addressOf(range.front);
|
||||||
for (range.popFront(); !range.empty; range.popFront())
|
for (range.popFront(); !range.empty; range.popFront())
|
||||||
{
|
{
|
||||||
if (binaryFun!pred(*p, range.front)) continue;
|
if (binaryFun!pred(*p, range.front)) continue;
|
||||||
if (binaryFun!pred(range.front, *p))
|
if (binaryFun!pred(range.front, *p))
|
||||||
{
|
{
|
||||||
// change the min
|
// change the min
|
||||||
p = &(range.front());
|
p = addressOf(range.front);
|
||||||
occurrences = 1;
|
occurrences = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -7111,10 +7111,8 @@ unittest
|
||||||
|
|
||||||
static struct R(T) //input range
|
static struct R(T) //input range
|
||||||
{
|
{
|
||||||
T[] a;
|
T[] arr;
|
||||||
bool empty() @property{return a.empty;}
|
alias arr this;
|
||||||
ref T front() @property{return a.front;}
|
|
||||||
void popFront() {a.popFront();}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
immutable a = [ 2, 3, 4, 1, 2, 4, 1, 1, 2 ];
|
immutable a = [ 2, 3, 4, 1, 2, 4, 1, 1, 2 ];
|
||||||
|
@ -7149,7 +7147,14 @@ unittest
|
||||||
static assert(!isAssignable!(S2, IS2));
|
static assert(!isAssignable!(S2, IS2));
|
||||||
static assert(!hasElaborateAssign!S2);
|
static assert(!hasElaborateAssign!S2);
|
||||||
|
|
||||||
foreach (Type; TypeTuple!(S1, immutable(S1), S2, immutable(S2)))
|
static struct S3
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
void opAssign(ref S3 other) @disable;
|
||||||
|
}
|
||||||
|
static assert(!isAssignable!S3);
|
||||||
|
|
||||||
|
foreach (Type; TypeTuple!(S1, IS1, S2, IS2, S3))
|
||||||
{
|
{
|
||||||
static if (is(Type == immutable)) alias V = immutable int;
|
static if (is(Type == immutable)) alias V = immutable int;
|
||||||
else alias V = int;
|
else alias V = int;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue