Add missing imports to public unittests

This commit is contained in:
Sebastian Wilzbach 2016-12-10 09:00:03 +01:00
parent 3f8298e853
commit cc7f125ed1
15 changed files with 49 additions and 8 deletions

View file

@ -1991,6 +1991,8 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
///
@safe pure unittest
{
import std.typecons : Yes;
assert(isPermutation([1, 2, 3], [3, 2, 1]));
assert(isPermutation([1.1, 2.3, 3.5], [2.3, 3.5, 1.1]));
assert(isPermutation("abc", "bca"));

View file

@ -4086,6 +4086,7 @@ if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(input.front))))
@safe unittest
{
import std.algorithm.comparison : equal;
import std.range.primitives : front;
assert(equal(splitter!(a => a == ' ')("hello world"), [ "hello", "", "world" ]));
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];

View file

@ -2588,6 +2588,7 @@ swapRanges(InputRange1, InputRange2)(InputRange1 r1, InputRange2 r2)
///
@safe unittest
{
import std.range : empty;
int[] a = [ 100, 101, 102, 103 ];
int[] b = [ 0, 1, 2, 3 ];
auto c = swapRanges(a[1 .. 3], b[2 .. 4]);

View file

@ -4177,6 +4177,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
@safe unittest
{
import std.algorithm.comparison : equal;
import std.typecons : No;
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
assert(equal(a.until(7), [1, 2, 4][]));
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7][]));

View file

@ -3558,6 +3558,8 @@ TRange topNCopy(alias less = "a < b", SRange, TRange)
///
unittest
{
import std.typecons : Yes;
int[] a = [ 10, 16, 2, 3, 1, 5, 0 ];
int[] b = new int[3];
topNCopy(a, b, Yes.sortOutput);
@ -3567,6 +3569,7 @@ unittest
unittest
{
import std.random : Random, unpredictableSeed, uniform, randomShuffle;
import std.typecons : Yes;
debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
@ -3679,6 +3682,8 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
///
unittest
{
import std.typecons : Yes;
// Construct index to top 3 elements using numerical indices:
int[] a = [ 10, 2, 7, 5, 8, 1 ];
int[] index = new int[3];
@ -3862,7 +3867,6 @@ if (isRandomAccessRange!Range && hasLength!Range &&
}
}
///
unittest
{
// Verify medianOf for all permutations of [1, 2, 2, 3, 4].