mirror of
https://github.com/dlang/phobos.git
synced 2025-05-06 11:07:39 +03:00
Add unittest for new joiner.
This commit is contained in:
parent
d489281292
commit
f83ad8a572
1 changed files with 41 additions and 0 deletions
|
@ -2900,6 +2900,47 @@ unittest
|
||||||
assert(!equal(js2, js));
|
assert(!equal(js2, js));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
struct TransientRange
|
||||||
|
{
|
||||||
|
dchar[128] _buf;
|
||||||
|
dstring[] _values;
|
||||||
|
this(dstring[] values)
|
||||||
|
{
|
||||||
|
_values = values;
|
||||||
|
}
|
||||||
|
@property bool empty()
|
||||||
|
{
|
||||||
|
return _values.length == 0;
|
||||||
|
}
|
||||||
|
@property auto front()
|
||||||
|
{
|
||||||
|
foreach (i; 0 .. _values.front.length)
|
||||||
|
{
|
||||||
|
_buf[i] = _values[0][i];
|
||||||
|
}
|
||||||
|
return _buf[0 .. _values.front.length];
|
||||||
|
}
|
||||||
|
void popFront()
|
||||||
|
{
|
||||||
|
_values = _values[1 .. $];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rr = TransientRange(["abc"d, "12"d, "def"d, "34"d]);
|
||||||
|
|
||||||
|
// Can't use array() or equal() directly because they fail with transient
|
||||||
|
// .front.
|
||||||
|
dchar[] result;
|
||||||
|
foreach (c; rr.joiner()) {
|
||||||
|
result ~= c;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(equal(result, "abc12def34"),
|
||||||
|
"Unexpected result: '%s'".format(result));
|
||||||
|
}
|
||||||
|
|
||||||
// uniq
|
// uniq
|
||||||
/**
|
/**
|
||||||
Iterates unique consecutive elements of the given range (functionality
|
Iterates unique consecutive elements of the given range (functionality
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue