mirror of
https://github.com/dlang/phobos.git
synced 2025-05-03 16:40:48 +03:00
Merge pull request #4814 from e-y-e/fixflags
[trivial] [large diff] Update uses of Flag to use the Yes/No structs.
This commit is contained in:
commit
2f8e693e5d
12 changed files with 1030 additions and 1030 deletions
|
@ -60,7 +60,7 @@ import std.functional; // : unaryFun, binaryFun;
|
||||||
import std.range.primitives;
|
import std.range.primitives;
|
||||||
import std.traits;
|
import std.traits;
|
||||||
// FIXME
|
// FIXME
|
||||||
import std.typecons; // : tuple, Tuple, Flag;
|
import std.typecons; // : tuple, Tuple, Flag, Yes;
|
||||||
import std.meta : allSatisfy;
|
import std.meta : allSatisfy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1805,8 +1805,8 @@ alias AllocateGC = Flag!"allocateGC";
|
||||||
/**
|
/**
|
||||||
Checks if both ranges are permutations of each other.
|
Checks if both ranges are permutations of each other.
|
||||||
|
|
||||||
This function can allocate if the $(D AllocateGC.yes) flag is passed. This has
|
This function can allocate if the $(D Yes.allocateGC) flag is passed. This has
|
||||||
the benefit of have better complexity than the $(D AllocateGC.no) option. However,
|
the benefit of have better complexity than the $(D Yes.allocateGC) option. However,
|
||||||
this option is only available for ranges whose equality can be determined via each
|
this option is only available for ranges whose equality can be determined via each
|
||||||
element's $(D toHash) method. If customized equality is needed, then the $(D pred)
|
element's $(D toHash) method. If customized equality is needed, then the $(D pred)
|
||||||
template parameter can be passed, and the function will automatically switch to
|
template parameter can be passed, and the function will automatically switch to
|
||||||
|
@ -1819,7 +1819,7 @@ Allocating forward range option: amortized $(BIGOH r1.length) + $(BIGOH r2.lengt
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
pred = an optional parameter to change how equality is defined
|
pred = an optional parameter to change how equality is defined
|
||||||
allocate_gc = AllocateGC.yes/no
|
allocate_gc = $(D Yes.allocateGC)/$(D No.allocateGC)
|
||||||
r1 = A finite forward range
|
r1 = A finite forward range
|
||||||
r2 = A finite forward range
|
r2 = A finite forward range
|
||||||
|
|
||||||
|
@ -1830,7 +1830,7 @@ Returns:
|
||||||
|
|
||||||
bool isPermutation(AllocateGC allocate_gc, Range1, Range2)
|
bool isPermutation(AllocateGC allocate_gc, Range1, Range2)
|
||||||
(Range1 r1, Range2 r2)
|
(Range1 r1, Range2 r2)
|
||||||
if (allocate_gc == AllocateGC.yes &&
|
if (allocate_gc == Yes.allocateGC &&
|
||||||
isForwardRange!Range1 &&
|
isForwardRange!Range1 &&
|
||||||
isForwardRange!Range2 &&
|
isForwardRange!Range2 &&
|
||||||
!isInfinite!Range1 &&
|
!isInfinite!Range1 &&
|
||||||
|
@ -1959,8 +1959,8 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
|
||||||
assert(!isPermutation([1, 1], [1, 1, 1]));
|
assert(!isPermutation([1, 1], [1, 1, 1]));
|
||||||
|
|
||||||
// Faster, but allocates GC handled memory
|
// Faster, but allocates GC handled memory
|
||||||
assert(isPermutation!(AllocateGC.yes)([1.1, 2.3, 3.5], [2.3, 3.5, 1.1]));
|
assert(isPermutation!(Yes.allocateGC)([1.1, 2.3, 3.5], [2.3, 3.5, 1.1]));
|
||||||
assert(!isPermutation!(AllocateGC.yes)([1, 2], [3, 4]));
|
assert(!isPermutation!(Yes.allocateGC)([1, 2], [3, 4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test @nogc inference
|
// Test @nogc inference
|
||||||
|
@ -1985,7 +1985,7 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
|
||||||
|
|
||||||
auto r3 = new ReferenceForwardRange!int([1, 2, 3, 4]);
|
auto r3 = new ReferenceForwardRange!int([1, 2, 3, 4]);
|
||||||
auto r4 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
auto r4 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
||||||
assert(isPermutation!(AllocateGC.yes)(r3, r4));
|
assert(isPermutation!(Yes.allocateGC)(r3, r4));
|
||||||
|
|
||||||
auto r5 = new ReferenceForwardRange!int([1, 2, 3]);
|
auto r5 = new ReferenceForwardRange!int([1, 2, 3]);
|
||||||
auto r6 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
auto r6 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
||||||
|
@ -1993,7 +1993,7 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
|
||||||
|
|
||||||
auto r7 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
auto r7 = new ReferenceForwardRange!int([4, 2, 1, 3]);
|
||||||
auto r8 = new ReferenceForwardRange!int([1, 2, 3]);
|
auto r8 = new ReferenceForwardRange!int([1, 2, 3]);
|
||||||
assert(!isPermutation!(AllocateGC.yes)(r7, r8));
|
assert(!isPermutation!(Yes.allocateGC)(r7, r8));
|
||||||
|
|
||||||
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r9;
|
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r9;
|
||||||
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r10;
|
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r10;
|
||||||
|
@ -2001,7 +2001,7 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
|
||||||
|
|
||||||
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r11;
|
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r11;
|
||||||
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r12;
|
DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random) r12;
|
||||||
assert(isPermutation!(AllocateGC.yes)(r11, r12));
|
assert(isPermutation!(Yes.allocateGC)(r11, r12));
|
||||||
|
|
||||||
alias mytuple = Tuple!(int, int);
|
alias mytuple = Tuple!(int, int);
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ import std.functional; // : unaryFun, binaryFun;
|
||||||
import std.range.primitives;
|
import std.range.primitives;
|
||||||
import std.traits;
|
import std.traits;
|
||||||
// FIXME
|
// FIXME
|
||||||
import std.typecons; // : Tuple, Flag;
|
import std.typecons; // : Tuple, Flag, Yes, No;
|
||||||
|
|
||||||
/++
|
/++
|
||||||
Checks if $(I _all) of the elements verify $(D pred).
|
Checks if $(I _all) of the elements verify $(D pred).
|
||||||
|
@ -3959,8 +3959,8 @@ Params:
|
||||||
to iterate over.
|
to iterate over.
|
||||||
sentinel = The element to stop at.
|
sentinel = The element to stop at.
|
||||||
openRight = Determines whether the element for which the given predicate is
|
openRight = Determines whether the element for which the given predicate is
|
||||||
true should be included in the resulting range ($(D OpenRight.no)), or
|
true should be included in the resulting range ($(D No.openRight)), or
|
||||||
not ($(D OpenRight.yes)).
|
not ($(D Yes.openRight)).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
An $(REF_ALTTEXT input _range, isInputRange, std,_range,primitives) that
|
An $(REF_ALTTEXT input _range, isInputRange, std,_range,primitives) that
|
||||||
|
@ -3971,7 +3971,7 @@ Returns:
|
||||||
*/
|
*/
|
||||||
Until!(pred, Range, Sentinel)
|
Until!(pred, Range, Sentinel)
|
||||||
until(alias pred = "a == b", Range, Sentinel)
|
until(alias pred = "a == b", Range, Sentinel)
|
||||||
(Range range, Sentinel sentinel, OpenRight openRight = OpenRight.yes)
|
(Range range, Sentinel sentinel, OpenRight openRight = Yes.openRight)
|
||||||
if (!is(Sentinel == OpenRight))
|
if (!is(Sentinel == OpenRight))
|
||||||
{
|
{
|
||||||
return typeof(return)(range, sentinel, openRight);
|
return typeof(return)(range, sentinel, openRight);
|
||||||
|
@ -3980,7 +3980,7 @@ if (!is(Sentinel == OpenRight))
|
||||||
/// Ditto
|
/// Ditto
|
||||||
Until!(pred, Range, void)
|
Until!(pred, Range, void)
|
||||||
until(alias pred, Range)
|
until(alias pred, Range)
|
||||||
(Range range, OpenRight openRight = OpenRight.yes)
|
(Range range, OpenRight openRight = Yes.openRight)
|
||||||
{
|
{
|
||||||
return typeof(return)(range, openRight);
|
return typeof(return)(range, openRight);
|
||||||
}
|
}
|
||||||
|
@ -4003,7 +4003,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
|
||||||
static if (!is(Sentinel == void))
|
static if (!is(Sentinel == void))
|
||||||
///
|
///
|
||||||
this(Range input, Sentinel sentinel,
|
this(Range input, Sentinel sentinel,
|
||||||
OpenRight openRight = OpenRight.yes)
|
OpenRight openRight = Yes.openRight)
|
||||||
{
|
{
|
||||||
_input = input;
|
_input = input;
|
||||||
_sentinel = sentinel;
|
_sentinel = sentinel;
|
||||||
|
@ -4012,7 +4012,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
///
|
///
|
||||||
this(Range input, OpenRight openRight = OpenRight.yes)
|
this(Range input, OpenRight openRight = Yes.openRight)
|
||||||
{
|
{
|
||||||
_input = input;
|
_input = input;
|
||||||
_openRight = openRight;
|
_openRight = openRight;
|
||||||
|
@ -4089,7 +4089,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
|
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), [1, 2, 4][]));
|
||||||
assert(equal(a.until(7, OpenRight.no), [1, 2, 4, 7][]));
|
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7][]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
@ -4099,12 +4099,12 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
|
||||||
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
|
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
|
||||||
|
|
||||||
static assert(isForwardRange!(typeof(a.until(7))));
|
static assert(isForwardRange!(typeof(a.until(7))));
|
||||||
static assert(isForwardRange!(typeof(until!"a == 2"(a, OpenRight.no))));
|
static assert(isForwardRange!(typeof(until!"a == 2"(a, No.openRight))));
|
||||||
|
|
||||||
assert(equal(a.until(7), [1, 2, 4][]));
|
assert(equal(a.until(7), [1, 2, 4][]));
|
||||||
assert(equal(a.until([7, 2]), [1, 2, 4, 7][]));
|
assert(equal(a.until([7, 2]), [1, 2, 4, 7][]));
|
||||||
assert(equal(a.until(7, OpenRight.no), [1, 2, 4, 7][]));
|
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7][]));
|
||||||
assert(equal(until!"a == 2"(a, OpenRight.no), [1, 2][]));
|
assert(equal(until!"a == 2"(a, No.openRight), [1, 2][]));
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest // bugzilla 13171
|
unittest // bugzilla 13171
|
||||||
|
@ -4112,7 +4112,7 @@ unittest // bugzilla 13171
|
||||||
import std.algorithm.comparison : equal;
|
import std.algorithm.comparison : equal;
|
||||||
import std.range;
|
import std.range;
|
||||||
auto a = [1, 2, 3, 4];
|
auto a = [1, 2, 3, 4];
|
||||||
assert(equal(refRange(&a).until(3, OpenRight.no), [1, 2, 3]));
|
assert(equal(refRange(&a).until(3, No.openRight), [1, 2, 3]));
|
||||||
assert(a == [4]);
|
assert(a == [4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import std.traits;
|
||||||
import std.meta; // : AliasSeq, staticMap, allSatisfy, anySatisfy;
|
import std.meta; // : AliasSeq, staticMap, allSatisfy, anySatisfy;
|
||||||
|
|
||||||
import std.algorithm.sorting; // : Merge;
|
import std.algorithm.sorting; // : Merge;
|
||||||
|
import std.typecons : No;
|
||||||
|
|
||||||
// cartesianProduct
|
// cartesianProduct
|
||||||
/**
|
/**
|
||||||
|
@ -574,7 +575,7 @@ duplicate in between calls).
|
||||||
*/
|
*/
|
||||||
void largestPartialIntersection
|
void largestPartialIntersection
|
||||||
(alias less = "a < b", RangeOfRanges, Range)
|
(alias less = "a < b", RangeOfRanges, Range)
|
||||||
(RangeOfRanges ror, Range tgt, SortOutput sorted = SortOutput.no)
|
(RangeOfRanges ror, Range tgt, SortOutput sorted = No.sortOutput)
|
||||||
{
|
{
|
||||||
struct UnitWeights
|
struct UnitWeights
|
||||||
{
|
{
|
||||||
|
@ -631,7 +632,7 @@ Params:
|
||||||
*/
|
*/
|
||||||
void largestPartialIntersectionWeighted
|
void largestPartialIntersectionWeighted
|
||||||
(alias less = "a < b", RangeOfRanges, Range, WeightsAA)
|
(alias less = "a < b", RangeOfRanges, Range, WeightsAA)
|
||||||
(RangeOfRanges ror, Range tgt, WeightsAA weights, SortOutput sorted = SortOutput.no)
|
(RangeOfRanges ror, Range tgt, WeightsAA weights, SortOutput sorted = No.sortOutput)
|
||||||
{
|
{
|
||||||
import std.algorithm.iteration : group;
|
import std.algorithm.iteration : group;
|
||||||
import std.algorithm.sorting : topNCopy;
|
import std.algorithm.sorting : topNCopy;
|
||||||
|
@ -672,7 +673,7 @@ unittest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.conv : text;
|
import std.conv : text;
|
||||||
import std.typecons : tuple, Tuple;
|
import std.typecons : tuple, Tuple, Yes;
|
||||||
|
|
||||||
debug(std_algorithm) scope(success)
|
debug(std_algorithm) scope(success)
|
||||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||||
|
@ -686,7 +687,7 @@ unittest
|
||||||
[ 7 ],
|
[ 7 ],
|
||||||
];
|
];
|
||||||
auto b = new Tuple!(double, uint)[2];
|
auto b = new Tuple!(double, uint)[2];
|
||||||
largestPartialIntersection(a, b, SortOutput.yes);
|
largestPartialIntersection(a, b, Yes.sortOutput);
|
||||||
//sort(b);
|
//sort(b);
|
||||||
//writeln(b);
|
//writeln(b);
|
||||||
assert(b == [ tuple(7.0, 4u), tuple(1.0, 3u) ][], text(b));
|
assert(b == [ tuple(7.0, 4u), tuple(1.0, 3u) ][], text(b));
|
||||||
|
@ -696,7 +697,7 @@ unittest
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.conv : text;
|
import std.conv : text;
|
||||||
import std.typecons : tuple, Tuple;
|
import std.typecons : tuple, Tuple, Yes;
|
||||||
|
|
||||||
debug(std_algorithm) scope(success)
|
debug(std_algorithm) scope(success)
|
||||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||||
|
@ -710,7 +711,7 @@ unittest
|
||||||
[ "7" ],
|
[ "7" ],
|
||||||
];
|
];
|
||||||
auto b = new Tuple!(string, uint)[2];
|
auto b = new Tuple!(string, uint)[2];
|
||||||
largestPartialIntersection(a, b, SortOutput.yes);
|
largestPartialIntersection(a, b, Yes.sortOutput);
|
||||||
//writeln(b);
|
//writeln(b);
|
||||||
assert(b == [ tuple("7", 4u), tuple("1", 3u) ][], text(b));
|
assert(b == [ tuple("7", 4u), tuple("1", 3u) ][], text(b));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3148,7 +3148,7 @@ Params:
|
||||||
Returns: The slice of `target` containing the copied elements.
|
Returns: The slice of `target` containing the copied elements.
|
||||||
*/
|
*/
|
||||||
TRange topNCopy(alias less = "a < b", SRange, TRange)
|
TRange topNCopy(alias less = "a < b", SRange, TRange)
|
||||||
(SRange source, TRange target, SortOutput sorted = SortOutput.no)
|
(SRange source, TRange target, SortOutput sorted = No.sortOutput)
|
||||||
if (isInputRange!(SRange) && isRandomAccessRange!(TRange)
|
if (isInputRange!(SRange) && isRandomAccessRange!(TRange)
|
||||||
&& hasLength!(TRange) && hasSlicing!(TRange))
|
&& hasLength!(TRange) && hasSlicing!(TRange))
|
||||||
{
|
{
|
||||||
|
@ -3158,7 +3158,7 @@ TRange topNCopy(alias less = "a < b", SRange, TRange)
|
||||||
auto heap = BinaryHeap!(TRange, less)(target, 0);
|
auto heap = BinaryHeap!(TRange, less)(target, 0);
|
||||||
foreach (e; source) heap.conditionalInsert(e);
|
foreach (e; source) heap.conditionalInsert(e);
|
||||||
auto result = target[0 .. heap.length];
|
auto result = target[0 .. heap.length];
|
||||||
if (sorted == SortOutput.yes)
|
if (sorted == Yes.sortOutput)
|
||||||
{
|
{
|
||||||
while (!heap.empty) heap.removeFront();
|
while (!heap.empty) heap.removeFront();
|
||||||
}
|
}
|
||||||
|
@ -3170,7 +3170,7 @@ unittest
|
||||||
{
|
{
|
||||||
int[] a = [ 10, 16, 2, 3, 1, 5, 0 ];
|
int[] a = [ 10, 16, 2, 3, 1, 5, 0 ];
|
||||||
int[] b = new int[3];
|
int[] b = new int[3];
|
||||||
topNCopy(a, b, SortOutput.yes);
|
topNCopy(a, b, Yes.sortOutput);
|
||||||
assert(b == [ 0, 1, 2 ]);
|
assert(b == [ 0, 1, 2 ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3187,7 +3187,7 @@ unittest
|
||||||
randomShuffle(a, r);
|
randomShuffle(a, r);
|
||||||
auto n = uniform(0, a.length, r);
|
auto n = uniform(0, a.length, r);
|
||||||
ptrdiff_t[] b = new ptrdiff_t[n];
|
ptrdiff_t[] b = new ptrdiff_t[n];
|
||||||
topNCopy!(binaryFun!("a < b"))(a, b, SortOutput.yes);
|
topNCopy!(binaryFun!("a < b"))(a, b, Yes.sortOutput);
|
||||||
assert(isSorted!(binaryFun!("a < b"))(b));
|
assert(isSorted!(binaryFun!("a < b"))(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3225,7 +3225,7 @@ ignored.
|
||||||
*/
|
*/
|
||||||
void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
||||||
Range, RangeIndex)
|
Range, RangeIndex)
|
||||||
(Range r, RangeIndex index, SortOutput sorted = SortOutput.no)
|
(Range r, RangeIndex index, SortOutput sorted = No.sortOutput)
|
||||||
if (isRandomAccessRange!Range &&
|
if (isRandomAccessRange!Range &&
|
||||||
isRandomAccessRange!RangeIndex &&
|
isRandomAccessRange!RangeIndex &&
|
||||||
hasAssignableElements!RangeIndex &&
|
hasAssignableElements!RangeIndex &&
|
||||||
|
@ -3249,7 +3249,7 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
||||||
{
|
{
|
||||||
heap.conditionalInsert(cast(ElementType!RangeIndex) i);
|
heap.conditionalInsert(cast(ElementType!RangeIndex) i);
|
||||||
}
|
}
|
||||||
if (sorted == SortOutput.yes)
|
if (sorted == Yes.sortOutput)
|
||||||
{
|
{
|
||||||
while (!heap.empty) heap.removeFront();
|
while (!heap.empty) heap.removeFront();
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3258,7 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
||||||
/// ditto
|
/// ditto
|
||||||
void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
||||||
Range, RangeIndex)
|
Range, RangeIndex)
|
||||||
(Range r, RangeIndex index, SortOutput sorted = SortOutput.no)
|
(Range r, RangeIndex index, SortOutput sorted = No.sortOutput)
|
||||||
if (isRandomAccessRange!Range &&
|
if (isRandomAccessRange!Range &&
|
||||||
isRandomAccessRange!RangeIndex &&
|
isRandomAccessRange!RangeIndex &&
|
||||||
hasAssignableElements!RangeIndex &&
|
hasAssignableElements!RangeIndex &&
|
||||||
|
@ -3280,7 +3280,7 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
|
||||||
{
|
{
|
||||||
heap.conditionalInsert(&r[i]);
|
heap.conditionalInsert(&r[i]);
|
||||||
}
|
}
|
||||||
if (sorted == SortOutput.yes)
|
if (sorted == Yes.sortOutput)
|
||||||
{
|
{
|
||||||
while (!heap.empty) heap.removeFront();
|
while (!heap.empty) heap.removeFront();
|
||||||
}
|
}
|
||||||
|
@ -3292,12 +3292,12 @@ unittest
|
||||||
// Construct index to top 3 elements using numerical indices:
|
// Construct index to top 3 elements using numerical indices:
|
||||||
int[] a = [ 10, 2, 7, 5, 8, 1 ];
|
int[] a = [ 10, 2, 7, 5, 8, 1 ];
|
||||||
int[] index = new int[3];
|
int[] index = new int[3];
|
||||||
topNIndex(a, index, SortOutput.yes);
|
topNIndex(a, index, Yes.sortOutput);
|
||||||
assert(index == [5, 1, 3]); // because a[5]==1, a[1]==2, a[3]==5
|
assert(index == [5, 1, 3]); // because a[5]==1, a[1]==2, a[3]==5
|
||||||
|
|
||||||
// Construct index to top 3 elements using pointer indices:
|
// Construct index to top 3 elements using pointer indices:
|
||||||
int*[] ptrIndex = new int*[3];
|
int*[] ptrIndex = new int*[3];
|
||||||
topNIndex(a, ptrIndex, SortOutput.yes);
|
topNIndex(a, ptrIndex, Yes.sortOutput);
|
||||||
assert(ptrIndex == [ &a[5], &a[1], &a[3] ]);
|
assert(ptrIndex == [ &a[5], &a[1], &a[3] ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3311,14 +3311,14 @@ unittest
|
||||||
{
|
{
|
||||||
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
||||||
int*[] b = new int*[5];
|
int*[] b = new int*[5];
|
||||||
topNIndex!("a > b")(a, b, SortOutput.yes);
|
topNIndex!("a > b")(a, b, Yes.sortOutput);
|
||||||
//foreach (e; b) writeln(*e);
|
//foreach (e; b) writeln(*e);
|
||||||
assert(b == [ &a[0], &a[2], &a[1], &a[6], &a[5]]);
|
assert(b == [ &a[0], &a[2], &a[1], &a[6], &a[5]]);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
int[] a = [ 10, 8, 9, 2, 4, 6, 7, 1, 3, 5 ];
|
||||||
auto b = new ubyte[5];
|
auto b = new ubyte[5];
|
||||||
topNIndex!("a > b")(a, b, SortOutput.yes);
|
topNIndex!("a > b")(a, b, Yes.sortOutput);
|
||||||
//foreach (e; b) writeln(e, ":", a[e]);
|
//foreach (e; b) writeln(e, ":", a[e]);
|
||||||
assert(b == [ cast(ubyte) 0, cast(ubyte)2, cast(ubyte)1, cast(ubyte)6, cast(ubyte)5], text(b));
|
assert(b == [ cast(ubyte) 0, cast(ubyte)2, cast(ubyte)1, cast(ubyte)6, cast(ubyte)5], text(b));
|
||||||
}
|
}
|
||||||
|
|
1085
std/datetime.d
1085
std/datetime.d
File diff suppressed because it is too large
Load diff
10
std/file.d
10
std/file.d
|
@ -3252,22 +3252,22 @@ alias PreserveAttributes = Flag!"preserveAttributes";
|
||||||
|
|
||||||
version (StdDdoc)
|
version (StdDdoc)
|
||||||
{
|
{
|
||||||
/// Defaults to PreserveAttributes.yes on Windows, and the opposite on all other platforms.
|
/// Defaults to $(D Yes.preserveAttributes) on Windows, and the opposite on all other platforms.
|
||||||
PreserveAttributes preserveAttributesDefault;
|
PreserveAttributes preserveAttributesDefault;
|
||||||
}
|
}
|
||||||
else version(Windows)
|
else version(Windows)
|
||||||
{
|
{
|
||||||
enum preserveAttributesDefault = PreserveAttributes.yes;
|
enum preserveAttributesDefault = Yes.preserveAttributes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enum preserveAttributesDefault = PreserveAttributes.no;
|
enum preserveAttributesDefault = No.preserveAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
Copy file $(D from) to file $(D to). File timestamps are preserved.
|
Copy file $(D from) to file $(D to). File timestamps are preserved.
|
||||||
File attributes are preserved, if $(D preserve) equals $(D PreserveAttributes.yes).
|
File attributes are preserved, if $(D preserve) equals $(D Yes.preserveAttributes).
|
||||||
On Windows only $(D PreserveAttributes.yes) (the default on Windows) is supported.
|
On Windows only $(D Yes.preserveAttributes) (the default on Windows) is supported.
|
||||||
If the target file exists, it is overwritten.
|
If the target file exists, it is overwritten.
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ struct ByLineBuffer(Char)
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* url = The url to receive content from
|
* url = The url to receive content from
|
||||||
* keepTerminator = KeepTerminator.yes signals that the line terminator should be
|
* keepTerminator = $(D Yes.keepTerminator) signals that the line terminator should be
|
||||||
* returned as part of the lines in the range.
|
* returned as part of the lines in the range.
|
||||||
* terminator = The character that terminates a line
|
* terminator = The character that terminates a line
|
||||||
* conn = The connection to use e.g. HTTP or FTP.
|
* conn = The connection to use e.g. HTTP or FTP.
|
||||||
|
@ -1224,7 +1224,7 @@ struct ByLineBuffer(Char)
|
||||||
* A range of Char[] with the content of the resource pointer to by the URL
|
* A range of Char[] with the content of the resource pointer to by the URL
|
||||||
*/
|
*/
|
||||||
auto byLine(Conn = AutoProtocol, Terminator = char, Char = char)
|
auto byLine(Conn = AutoProtocol, Terminator = char, Char = char)
|
||||||
(const(char)[] url, KeepTerminator keepTerminator = KeepTerminator.no,
|
(const(char)[] url, KeepTerminator keepTerminator = No.keepTerminator,
|
||||||
Terminator terminator = '\n', Conn conn = Conn())
|
Terminator terminator = '\n', Conn conn = Conn())
|
||||||
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
|
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
|
||||||
{
|
{
|
||||||
|
@ -1290,7 +1290,7 @@ if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = _getForRange!Char(url, conn);
|
auto result = _getForRange!Char(url, conn);
|
||||||
return SyncLineInputRange(result, keepTerminator == KeepTerminator.yes, terminator);
|
return SyncLineInputRange(result, keepTerminator == Yes.keepTerminator, terminator);
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
|
@ -1590,7 +1590,7 @@ private static struct AsyncLineInputRange(Char)
|
||||||
* Params:
|
* Params:
|
||||||
* url = The url to receive content from
|
* url = The url to receive content from
|
||||||
* postData = Data to HTTP Post
|
* postData = Data to HTTP Post
|
||||||
* keepTerminator = KeepTerminator.yes signals that the line terminator should be
|
* keepTerminator = $(D Yes.keepTerminator) signals that the line terminator should be
|
||||||
* returned as part of the lines in the range.
|
* returned as part of the lines in the range.
|
||||||
* terminator = The character that terminates a line
|
* terminator = The character that terminates a line
|
||||||
* transmitBuffers = The number of lines buffered asynchronously
|
* transmitBuffers = The number of lines buffered asynchronously
|
||||||
|
@ -1602,7 +1602,7 @@ private static struct AsyncLineInputRange(Char)
|
||||||
*/
|
*/
|
||||||
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
|
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
|
||||||
(const(char)[] url, const(PostUnit)[] postData,
|
(const(char)[] url, const(PostUnit)[] postData,
|
||||||
KeepTerminator keepTerminator = KeepTerminator.no,
|
KeepTerminator keepTerminator = No.keepTerminator,
|
||||||
Terminator terminator = '\n',
|
Terminator terminator = '\n',
|
||||||
size_t transmitBuffers = 10, Conn conn = Conn())
|
size_t transmitBuffers = 10, Conn conn = Conn())
|
||||||
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
|
if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator)
|
||||||
|
@ -1623,7 +1623,7 @@ auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
|
||||||
auto tid = spawn(&_spawnAsync!(Conn, Char, Terminator));
|
auto tid = spawn(&_spawnAsync!(Conn, Char, Terminator));
|
||||||
tid.send(thisTid);
|
tid.send(thisTid);
|
||||||
tid.send(terminator);
|
tid.send(terminator);
|
||||||
tid.send(keepTerminator == KeepTerminator.yes);
|
tid.send(keepTerminator == Yes.keepTerminator);
|
||||||
|
|
||||||
_asyncDuplicateConnection(url, conn, postData, tid);
|
_asyncDuplicateConnection(url, conn, postData, tid);
|
||||||
|
|
||||||
|
@ -1634,7 +1634,7 @@ auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char, PostUnit)
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char)
|
auto byLineAsync(Conn = AutoProtocol, Terminator = char, Char = char)
|
||||||
(const(char)[] url, KeepTerminator keepTerminator = KeepTerminator.no,
|
(const(char)[] url, KeepTerminator keepTerminator = No.keepTerminator,
|
||||||
Terminator terminator = '\n',
|
Terminator terminator = '\n',
|
||||||
size_t transmitBuffers = 10, Conn conn = Conn())
|
size_t transmitBuffers = 10, Conn conn = Conn())
|
||||||
{
|
{
|
||||||
|
@ -2493,7 +2493,7 @@ struct HTTP
|
||||||
Params:
|
Params:
|
||||||
throwOnError = whether to throw an exception or return a CurlCode on error
|
throwOnError = whether to throw an exception or return a CurlCode on error
|
||||||
*/
|
*/
|
||||||
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
|
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
|
||||||
{
|
{
|
||||||
p.status.reset();
|
p.status.reset();
|
||||||
|
|
||||||
|
@ -3246,7 +3246,7 @@ struct FTP
|
||||||
Params:
|
Params:
|
||||||
throwOnError = whether to throw an exception or return a CurlCode on error
|
throwOnError = whether to throw an exception or return a CurlCode on error
|
||||||
*/
|
*/
|
||||||
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
|
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
|
||||||
{
|
{
|
||||||
return p.curl.perform(throwOnError);
|
return p.curl.perform(throwOnError);
|
||||||
}
|
}
|
||||||
|
@ -3577,7 +3577,7 @@ struct SMTP
|
||||||
Params:
|
Params:
|
||||||
throwOnError = whether to throw an exception or return a CurlCode on error
|
throwOnError = whether to throw an exception or return a CurlCode on error
|
||||||
*/
|
*/
|
||||||
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
|
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
|
||||||
{
|
{
|
||||||
return p.curl.perform(throwOnError);
|
return p.curl.perform(throwOnError);
|
||||||
}
|
}
|
||||||
|
@ -3859,7 +3859,7 @@ class CurlTimeoutException : CurlException
|
||||||
/// Equal to $(REF CURLcode, etc,c,curl)
|
/// Equal to $(REF CURLcode, etc,c,curl)
|
||||||
alias CurlCode = CURLcode;
|
alias CurlCode = CURLcode;
|
||||||
|
|
||||||
import std.typecons : Flag;
|
import std.typecons : Flag, Yes, No;
|
||||||
/// Flag to specify whether or not an exception is thrown on error.
|
/// Flag to specify whether or not an exception is thrown on error.
|
||||||
alias ThrowOnError = Flag!"throwOnError";
|
alias ThrowOnError = Flag!"throwOnError";
|
||||||
|
|
||||||
|
@ -4205,7 +4205,7 @@ struct Curl
|
||||||
Params:
|
Params:
|
||||||
throwOnError = whether to throw an exception or return a CurlCode on error
|
throwOnError = whether to throw an exception or return a CurlCode on error
|
||||||
*/
|
*/
|
||||||
CurlCode perform(ThrowOnError throwOnError = ThrowOnError.yes)
|
CurlCode perform(ThrowOnError throwOnError = Yes.throwOnError)
|
||||||
{
|
{
|
||||||
throwOnStopped();
|
throwOnStopped();
|
||||||
CurlCode code = curl.easy_perform(this.handle);
|
CurlCode code = curl.easy_perform(this.handle);
|
||||||
|
@ -4812,7 +4812,7 @@ private static void _spawnAsync(Conn, Unit, Terminator = void)()
|
||||||
CurlCode code;
|
CurlCode code;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
code = client.perform(ThrowOnError.no);
|
code = client.perform(No.throwOnError);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ module std.net.isemail;
|
||||||
// FIXME
|
// FIXME
|
||||||
import std.range.primitives; // : ElementType;
|
import std.range.primitives; // : ElementType;
|
||||||
import std.traits;
|
import std.traits;
|
||||||
import std.typecons : Flag;
|
import std.typecons : Flag, Yes, No;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that an email address conforms to RFCs 5321, 5322 and others.
|
* Check that an email address conforms to RFCs 5321, 5322 and others.
|
||||||
|
@ -41,7 +41,7 @@ import std.typecons : Flag;
|
||||||
*
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* email = The email address to check
|
* email = The email address to check
|
||||||
* checkDNS = If CheckDns.yes then a DNS check for MX records will be made
|
* checkDNS = If $(D Yes.checkDns) then a DNS check for MX records will be made
|
||||||
* errorLevel = Determines the boundary between valid and invalid addresses.
|
* errorLevel = Determines the boundary between valid and invalid addresses.
|
||||||
* Status codes above this number will be returned as-is,
|
* Status codes above this number will be returned as-is,
|
||||||
* status codes below will be returned as EmailStatusCode.valid.
|
* status codes below will be returned as EmailStatusCode.valid.
|
||||||
|
@ -57,7 +57,7 @@ import std.typecons : Flag;
|
||||||
*
|
*
|
||||||
* Returns: an EmailStatus, indicating the status of the email address.
|
* Returns: an EmailStatus, indicating the status of the email address.
|
||||||
*/
|
*/
|
||||||
EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no,
|
EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = No.checkDns,
|
||||||
EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char))
|
EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char))
|
||||||
{
|
{
|
||||||
import std.algorithm.iteration : uniq;
|
import std.algorithm.iteration : uniq;
|
||||||
|
@ -730,7 +730,7 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
|
||||||
|
|
||||||
auto dnsChecked = false;
|
auto dnsChecked = false;
|
||||||
|
|
||||||
if (checkDNS == CheckDns.yes && returnStatus.max() < EmailStatusCode.dnsWarning)
|
if (checkDNS == Yes.checkDns && returnStatus.max() < EmailStatusCode.dnsWarning)
|
||||||
{
|
{
|
||||||
assert(false, "DNS check is currently not implemented");
|
assert(false, "DNS check is currently not implemented");
|
||||||
}
|
}
|
||||||
|
@ -773,478 +773,478 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
assert(`test.test@iana.org`.isEmail(CheckDns.no).statusCode == EmailStatusCode.valid);
|
assert(`test.test@iana.org`.isEmail(No.checkDns).statusCode == EmailStatusCode.valid);
|
||||||
assert(`test.test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.none).statusCode == EmailStatusCode.valid);
|
assert(`test.test@iana.org`.isEmail(No.checkDns, EmailStatusCode.none).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::8888]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::8888]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.none).statusCode == EmailStatusCode.valid);
|
EmailStatusCode.none).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`test`.isEmail(CheckDns.no, EmailStatusCode.none).statusCode == EmailStatusCode.error);
|
assert(`test`.isEmail(No.checkDns, EmailStatusCode.none).statusCode == EmailStatusCode.error);
|
||||||
assert(`(comment)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.none).statusCode == EmailStatusCode.error);
|
assert(`(comment)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.none).statusCode == EmailStatusCode.error);
|
||||||
|
|
||||||
assert(``.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
assert(``.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
||||||
assert(`test`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
assert(`test`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
||||||
assert(`@`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart);
|
assert(`@`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart);
|
||||||
assert(`test@`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
assert(`test@`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
||||||
|
|
||||||
// assert(`test@io`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid,
|
// assert(`test@io`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid,
|
||||||
// `io. currently has an MX-record (Feb 2011). Some DNS setups seem to find it, some don't.`
|
// `io. currently has an MX-record (Feb 2011). Some DNS setups seem to find it, some don't.`
|
||||||
// ` If you don't see the MX for io. then try setting your DNS server to 8.8.8.8 (the Google DNS server)`);
|
// ` If you don't see the MX for io. then try setting your DNS server to 8.8.8.8 (the Google DNS server)`);
|
||||||
|
|
||||||
assert(`@io`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart,
|
assert(`@io`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart,
|
||||||
`io. currently has an MX-record (Feb 2011)`);
|
`io. currently has an MX-record (Feb 2011)`);
|
||||||
|
|
||||||
assert(`@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart);
|
assert(`@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoLocalPart);
|
||||||
assert(`test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
assert(`test@nominet.org.uk`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@nominet.org.uk`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
assert(`test@about.museum`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@about.museum`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
assert(`a@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`a@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
//assert(`test@e.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
//assert(`test@e.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
||||||
// DNS check is currently not implemented
|
// DNS check is currently not implemented
|
||||||
|
|
||||||
//assert(`test@iana.a`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
//assert(`test@iana.a`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
||||||
// DNS check is currently not implemented
|
// DNS check is currently not implemented
|
||||||
|
|
||||||
assert(`test.test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test.test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
assert(`.test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotStart);
|
assert(`.test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotStart);
|
||||||
assert(`test.@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotEnd);
|
assert(`test.@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotEnd);
|
||||||
|
|
||||||
assert(`test..iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test..iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorConsecutiveDots);
|
EmailStatusCode.errorConsecutiveDots);
|
||||||
|
|
||||||
assert(`test_exa-mple.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
assert(`test_exa-mple.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorNoDomain);
|
||||||
assert("!#$%&`*+/=?^`{|}~@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert("!#$%&`*+/=?^`{|}~@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`test\@test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test\@test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`123@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`123@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
assert(`test@123.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@123.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`test@iana.123`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana.123`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321TopLevelDomainNumeric);
|
EmailStatusCode.rfc5321TopLevelDomainNumeric);
|
||||||
assert(`test@255.255.255.255`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@255.255.255.255`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321TopLevelDomainNumeric);
|
EmailStatusCode.rfc5321TopLevelDomainNumeric);
|
||||||
|
|
||||||
assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org`.isEmail(CheckDns.no,
|
assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklmn@iana.org`.isEmail(CheckDns.no,
|
assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklmn@iana.org`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong);
|
||||||
|
|
||||||
// assert(`test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.com`.isEmail(CheckDns.no,
|
// assert(`test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.com`.isEmail(No.checkDns,
|
||||||
// EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
// EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
||||||
// DNS check is currently not implemented
|
// DNS check is currently not implemented
|
||||||
|
|
||||||
assert(`test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm.com`.isEmail(CheckDns.no,
|
assert(`test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm.com`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LabelTooLong);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LabelTooLong);
|
||||||
|
|
||||||
assert(`test@mason-dixon.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@mason-dixon.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
assert(`test@-iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@-iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorDomainHyphenStart);
|
EmailStatusCode.errorDomainHyphenStart);
|
||||||
|
|
||||||
assert(`test@iana-.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana-.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorDomainHyphenEnd);
|
EmailStatusCode.errorDomainHyphenEnd);
|
||||||
|
|
||||||
assert(`test@g--a.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
assert(`test@g--a.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid);
|
||||||
|
|
||||||
//assert(`test@iana.co-uk`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
//assert(`test@iana.co-uk`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
//EmailStatusCode.dnsWarningNoRecord); // DNS check is currently not implemented
|
//EmailStatusCode.dnsWarningNoRecord); // DNS check is currently not implemented
|
||||||
|
|
||||||
assert(`test@.iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotStart);
|
assert(`test@.iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotStart);
|
||||||
assert(`test@iana.org.`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotEnd);
|
assert(`test@iana.org.`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorDotEnd);
|
||||||
assert(`test@iana..com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana..com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorConsecutiveDots);
|
EmailStatusCode.errorConsecutiveDots);
|
||||||
|
|
||||||
//assert(`a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z`
|
//assert(`a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z`
|
||||||
// `.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z`
|
// `.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z`
|
||||||
// `.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
// `.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
// EmailStatusCode.dnsWarningNoRecord); // DNS check is currently not implemented
|
// EmailStatusCode.dnsWarningNoRecord); // DNS check is currently not implemented
|
||||||
|
|
||||||
// assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyz`
|
// assert(`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyz`
|
||||||
// `abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`
|
// `abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`
|
||||||
// `abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi`.isEmail(CheckDns.no,
|
// `abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi`.isEmail(No.checkDns,
|
||||||
// EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
// EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord);
|
||||||
// DNS check is currently not implemented
|
// DNS check is currently not implemented
|
||||||
|
|
||||||
assert((`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyz`~
|
assert((`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@abcdefghijklmnopqrstuvwxyz`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij`).isEmail(CheckDns.no,
|
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij`).isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322TooLong);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322TooLong);
|
||||||
|
|
||||||
assert((`a@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyz`~
|
assert((`a@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyz`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hij`).isEmail(CheckDns.no,
|
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hij`).isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322TooLong);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322TooLong);
|
||||||
|
|
||||||
assert((`a@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyz`~
|
assert((`a@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyz`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
`abcdefghijklmnopqrstuvwxyzabcdefghikl.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hijk`).isEmail(CheckDns.no,
|
`abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hijk`).isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322DomainTooLong);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322DomainTooLong);
|
||||||
|
|
||||||
assert(`"test"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321QuotedString);
|
EmailStatusCode.rfc5321QuotedString);
|
||||||
|
|
||||||
assert(`""@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
assert(`""@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
||||||
assert(`"""@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
|
assert(`"""@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
|
||||||
assert(`"\a"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
assert(`"\a"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
||||||
assert(`"\""@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
assert(`"\""@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
||||||
|
|
||||||
assert(`"\"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"\"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedQuotedString);
|
EmailStatusCode.errorUnclosedQuotedString);
|
||||||
|
|
||||||
assert(`"\\"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
assert(`"\\"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321QuotedString);
|
||||||
assert(`test"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
|
assert(`test"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`"test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedQuotedString);
|
EmailStatusCode.errorUnclosedQuotedString);
|
||||||
|
|
||||||
assert(`"test"test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test"test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorTextAfterQuotedString);
|
EmailStatusCode.errorTextAfterQuotedString);
|
||||||
|
|
||||||
assert(`test"text"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test"text"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`"test""test"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test""test"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`"test"."test"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test"."test"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedLocalPart);
|
EmailStatusCode.deprecatedLocalPart);
|
||||||
|
|
||||||
assert(`"test\ test"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test\ test"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321QuotedString);
|
EmailStatusCode.rfc5321QuotedString);
|
||||||
|
|
||||||
assert(`"test".test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test".test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedLocalPart);
|
EmailStatusCode.deprecatedLocalPart);
|
||||||
|
|
||||||
assert("\"test\u0000\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"test\u0000\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingQuotedText);
|
EmailStatusCode.errorExpectingQuotedText);
|
||||||
|
|
||||||
assert("\"test\\\u0000\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"test\\\u0000\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedPair);
|
EmailStatusCode.deprecatedQuotedPair);
|
||||||
|
|
||||||
assert(`"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghj"@iana.org`.isEmail(CheckDns.no,
|
assert(`"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghj"@iana.org`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong,
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong,
|
||||||
`Quotes are still part of the length restriction`);
|
`Quotes are still part of the length restriction`);
|
||||||
|
|
||||||
assert(`"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefg\h"@iana.org`.isEmail(CheckDns.no,
|
assert(`"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefg\h"@iana.org`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong,
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322LocalTooLong,
|
||||||
`Quoted pair is still part of the length restriction`);
|
`Quoted pair is still part of the length restriction`);
|
||||||
|
|
||||||
assert(`test@[255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@a[255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@a[255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`test@[255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert(`test@[255.255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[255.255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert(`test@[255.255.255.256]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[255.255.255.256]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert(`test@[1111:2222:3333:4444:5555:6666:7777:8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[1111:2222:3333:4444:5555:6666:7777:8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322IpV6GroupCount);
|
EmailStatusCode.rfc5322IpV6GroupCount);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode
|
||||||
== EmailStatusCode.rfc5321AddressLiteral);
|
== EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:888G]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:888G]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6BadChar);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6BadChar);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::8888]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::8888]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321IpV6Deprecated);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321IpV6Deprecated);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555::8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:1111:2222:3333:4444:5555::8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::7777:8888]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::7777:8888]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6MaxGroups);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6MaxGroups);
|
||||||
|
|
||||||
assert(`test@[IPv6::3333:4444:5555:6666:7777:8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6::3333:4444:5555:6666:7777:8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322IpV6ColonStart);
|
EmailStatusCode.rfc5322IpV6ColonStart);
|
||||||
|
|
||||||
assert(`test@[IPv6:::3333:4444:5555:6666:7777:8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:::3333:4444:5555:6666:7777:8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111::4444:5555::8888]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:1111::4444:5555::8888]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322IpV6TooManyDoubleColons);
|
EmailStatusCode.rfc5322IpV6TooManyDoubleColons);
|
||||||
|
|
||||||
assert(`test@[IPv6:::]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:::]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:255.255.255.255]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:255.255.255.255]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:255.255.255.255]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666:7777:255.255.255.255]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6GroupCount);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444::255.255.255.255]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444::255.255.255.255]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321AddressLiteral);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321AddressLiteral);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::255.255.255.255]`.isEmail(CheckDns.no,
|
assert(`test@[IPv6:1111:2222:3333:4444:5555:6666::255.255.255.255]`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6MaxGroups);
|
EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322IpV6MaxGroups);
|
||||||
|
|
||||||
assert(`test@[IPv6:1111:2222:3333:4444:::255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode
|
assert(`test@[IPv6:1111:2222:3333:4444:::255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode
|
||||||
== EmailStatusCode.rfc5322IpV6TooManyDoubleColons);
|
== EmailStatusCode.rfc5322IpV6TooManyDoubleColons);
|
||||||
|
|
||||||
assert(`test@[IPv6::255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6::255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322IpV6ColonStart);
|
EmailStatusCode.rfc5322IpV6ColonStart);
|
||||||
|
|
||||||
assert(` test @iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(` test @iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
||||||
|
|
||||||
assert(`test@ iana .com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@ iana .com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
||||||
|
|
||||||
assert(`test . test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test . test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedFoldingWhitespace);
|
EmailStatusCode.deprecatedFoldingWhitespace);
|
||||||
|
|
||||||
assert("\u000D\u000A test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u000D\u000A test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.foldingWhitespace, `Folding whitespace`);
|
EmailStatusCode.foldingWhitespace, `Folding whitespace`);
|
||||||
|
|
||||||
assert("\u000D\u000A \u000D\u000A test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u000D\u000A \u000D\u000A test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedFoldingWhitespace, `FWS with one line composed entirely of WSP`~
|
EmailStatusCode.deprecatedFoldingWhitespace, `FWS with one line composed entirely of WSP`~
|
||||||
` -- only allowed as obsolete FWS (someone might allow only non-obsolete FWS)`);
|
` -- only allowed as obsolete FWS (someone might allow only non-obsolete FWS)`);
|
||||||
|
|
||||||
assert(`(comment)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
assert(`(comment)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
||||||
assert(`((comment)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`((comment)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedComment);
|
EmailStatusCode.errorUnclosedComment);
|
||||||
|
|
||||||
assert(`(comment(comment))test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`(comment(comment))test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.comment);
|
EmailStatusCode.comment);
|
||||||
|
|
||||||
assert(`test@(comment)iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@(comment)iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
||||||
|
|
||||||
assert(`test(comment)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test(comment)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorTextAfterCommentFoldingWhitespace);
|
EmailStatusCode.errorTextAfterCommentFoldingWhitespace);
|
||||||
|
|
||||||
assert(`test@(comment)[255.255.255.255]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@(comment)[255.255.255.255]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
||||||
|
|
||||||
assert(`(comment)abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org`.isEmail(CheckDns.no,
|
assert(`(comment)abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
||||||
|
|
||||||
assert(`test@(comment)abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.com`.isEmail(CheckDns.no,
|
assert(`test@(comment)abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl.com`.isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
EmailStatusCode.any).statusCode == EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt);
|
||||||
|
|
||||||
assert((`(comment)test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyz`~
|
assert((`(comment)test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyz`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.`~
|
`abcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.`~
|
||||||
`abcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstu`).isEmail(CheckDns.no,
|
`abcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstu`).isEmail(No.checkDns,
|
||||||
EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
EmailStatusCode.any).statusCode == EmailStatusCode.comment);
|
||||||
|
|
||||||
assert("test@iana.org\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert(`test@xn--hxajbheg2az3al.xn--jxalpdlp`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@xn--hxajbheg2az3al.xn--jxalpdlp`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.valid, `A valid IDN from ICANN's <a href="http://idn.icann.org/#The_example.test_names">`~
|
EmailStatusCode.valid, `A valid IDN from ICANN's <a href="http://idn.icann.org/#The_example.test_names">`~
|
||||||
`IDN TLD evaluation gateway</a>`);
|
`IDN TLD evaluation gateway</a>`);
|
||||||
|
|
||||||
assert(`xn--test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.valid,
|
assert(`xn--test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.valid,
|
||||||
`RFC 3490: "unless the email standards are revised to invite the use of IDNA for local parts, a domain label`~
|
`RFC 3490: "unless the email standards are revised to invite the use of IDNA for local parts, a domain label`~
|
||||||
` that holds the local part of an email address SHOULD NOT begin with the ACE prefix, and even if it does,`~
|
` that holds the local part of an email address SHOULD NOT begin with the ACE prefix, and even if it does,`~
|
||||||
` it is to be interpreted literally as a local part that happens to begin with the ACE prefix"`);
|
` it is to be interpreted literally as a local part that happens to begin with the ACE prefix"`);
|
||||||
|
|
||||||
assert(`test@iana.org-`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana.org-`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorDomainHyphenEnd);
|
EmailStatusCode.errorDomainHyphenEnd);
|
||||||
|
|
||||||
assert(`"test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedQuotedString);
|
EmailStatusCode.errorUnclosedQuotedString);
|
||||||
|
|
||||||
assert(`(test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`(test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedComment);
|
EmailStatusCode.errorUnclosedComment);
|
||||||
|
|
||||||
assert(`test@(iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@(iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedComment);
|
EmailStatusCode.errorUnclosedComment);
|
||||||
|
|
||||||
assert(`test@[1.2.3.4`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[1.2.3.4`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedDomainLiteral);
|
EmailStatusCode.errorUnclosedDomainLiteral);
|
||||||
|
|
||||||
assert(`"test\"@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`"test\"@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedQuotedString);
|
EmailStatusCode.errorUnclosedQuotedString);
|
||||||
|
|
||||||
assert(`(comment\)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`(comment\)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedComment);
|
EmailStatusCode.errorUnclosedComment);
|
||||||
|
|
||||||
assert(`test@iana.org(comment\)`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana.org(comment\)`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedComment);
|
EmailStatusCode.errorUnclosedComment);
|
||||||
|
|
||||||
assert(`test@iana.org(comment\`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@iana.org(comment\`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorBackslashEnd);
|
EmailStatusCode.errorBackslashEnd);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-domain-literal]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-domain-literal]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert(`test@[RFC-5322]-domain-literal]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322]-domain-literal]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorTextAfterDomainLiteral);
|
EmailStatusCode.errorTextAfterDomainLiteral);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-[domain-literal]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-[domain-literal]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingDomainText);
|
EmailStatusCode.errorExpectingDomainText);
|
||||||
|
|
||||||
assert("test@[RFC-5322-\\\u0007-domain-literal]".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@[RFC-5322-\\\u0007-domain-literal]".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteralObsoleteText, `obs-dtext <strong>and</strong> obs-qp`);
|
EmailStatusCode.rfc5322DomainLiteralObsoleteText, `obs-dtext <strong>and</strong> obs-qp`);
|
||||||
|
|
||||||
assert("test@[RFC-5322-\\\u0009-domain-literal]".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@[RFC-5322-\\\u0009-domain-literal]".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteralObsoleteText);
|
EmailStatusCode.rfc5322DomainLiteralObsoleteText);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-\]-domain-literal]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-\]-domain-literal]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteralObsoleteText);
|
EmailStatusCode.rfc5322DomainLiteralObsoleteText);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-domain-literal\]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-domain-literal\]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorUnclosedDomainLiteral);
|
EmailStatusCode.errorUnclosedDomainLiteral);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-domain-literal\`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-domain-literal\`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorBackslashEnd);
|
EmailStatusCode.errorBackslashEnd);
|
||||||
|
|
||||||
assert(`test@[RFC 5322 domain literal]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC 5322 domain literal]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral, `Spaces are FWS in a domain literal`);
|
EmailStatusCode.rfc5322DomainLiteral, `Spaces are FWS in a domain literal`);
|
||||||
|
|
||||||
assert(`test@[RFC-5322-domain-literal] (comment)`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[RFC-5322-domain-literal] (comment)`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322DomainLiteral);
|
EmailStatusCode.rfc5322DomainLiteral);
|
||||||
|
|
||||||
assert("\u007F@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u007F@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
assert("test@\u007F.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@\u007F.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
assert("\"\u007F\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\u007F\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedText);
|
EmailStatusCode.deprecatedQuotedText);
|
||||||
|
|
||||||
assert("\"\\\u007F\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\\\u007F\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedPair);
|
EmailStatusCode.deprecatedQuotedPair);
|
||||||
|
|
||||||
assert("(\u007F)test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("(\u007F)test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentText);
|
EmailStatusCode.deprecatedCommentText);
|
||||||
|
|
||||||
assert("test@iana.org\u000D".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
assert("test@iana.org\u000D".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
||||||
`No LF after the CR`);
|
`No LF after the CR`);
|
||||||
|
|
||||||
assert("\u000Dtest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
assert("\u000Dtest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
||||||
`No LF after the CR`);
|
`No LF after the CR`);
|
||||||
|
|
||||||
assert("\"\u000Dtest\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\u000Dtest\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorCrNoLf, `No LF after the CR`);
|
EmailStatusCode.errorCrNoLf, `No LF after the CR`);
|
||||||
|
|
||||||
assert("(\u000D)test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
assert("(\u000D)test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
||||||
`No LF after the CR`);
|
`No LF after the CR`);
|
||||||
|
|
||||||
assert("(\u000D".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
assert("(\u000D".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
||||||
`No LF after the CR`);
|
`No LF after the CR`);
|
||||||
|
|
||||||
assert("test@iana.org(\u000D)".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
assert("test@iana.org(\u000D)".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
|
||||||
`No LF after the CR`);
|
`No LF after the CR`);
|
||||||
|
|
||||||
assert("\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert("\"\u000A\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\u000A\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingQuotedText);
|
EmailStatusCode.errorExpectingQuotedText);
|
||||||
|
|
||||||
assert("\"\\\u000A\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\\\u000A\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedPair);
|
EmailStatusCode.deprecatedQuotedPair);
|
||||||
|
|
||||||
assert("(\u000A)test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("(\u000A)test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingCommentText);
|
EmailStatusCode.errorExpectingCommentText);
|
||||||
|
|
||||||
assert("\u0007@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u0007@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert("test@\u0007.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@\u0007.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingText);
|
EmailStatusCode.errorExpectingText);
|
||||||
|
|
||||||
assert("\"\u0007\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\u0007\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedText);
|
EmailStatusCode.deprecatedQuotedText);
|
||||||
|
|
||||||
assert("\"\\\u0007\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"\\\u0007\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedQuotedPair);
|
EmailStatusCode.deprecatedQuotedPair);
|
||||||
|
|
||||||
assert("(\u0007)test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("(\u0007)test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedCommentText);
|
EmailStatusCode.deprecatedCommentText);
|
||||||
|
|
||||||
assert("\u000D\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u000D\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no actual white space`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no actual white space`);
|
||||||
|
|
||||||
assert("\u000D\u000A \u000D\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\u000D\u000A \u000D\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not obs-FWS because there must be white space on each "fold"`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not obs-FWS because there must be white space on each "fold"`);
|
||||||
|
|
||||||
assert(" \u000D\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(" \u000D\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the fold`);
|
||||||
|
|
||||||
assert(" \u000D\u000A test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(" \u000D\u000A test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.foldingWhitespace, `FWS`);
|
EmailStatusCode.foldingWhitespace, `FWS`);
|
||||||
|
|
||||||
assert(" \u000D\u000A \u000D\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(" \u000D\u000A \u000D\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the second fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the second fold`);
|
||||||
|
|
||||||
assert(" \u000D\u000A\u000D\u000Atest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(" \u000D\u000A\u000D\u000Atest@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after either fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after either fold`);
|
||||||
|
|
||||||
assert(" \u000D\u000A\u000D\u000A test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(" \u000D\u000A\u000D\u000A test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after the first fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after the first fold`);
|
||||||
|
|
||||||
assert("test@iana.org\u000D\u000A ".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org\u000D\u000A ".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.foldingWhitespace, `FWS`);
|
EmailStatusCode.foldingWhitespace, `FWS`);
|
||||||
|
|
||||||
assert("test@iana.org\u000D\u000A \u000D\u000A ".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org\u000D\u000A \u000D\u000A ".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedFoldingWhitespace, `FWS with one line composed entirely of WSP -- `~
|
EmailStatusCode.deprecatedFoldingWhitespace, `FWS with one line composed entirely of WSP -- `~
|
||||||
`only allowed as obsolete FWS (someone might allow only non-obsolete FWS)`);
|
`only allowed as obsolete FWS (someone might allow only non-obsolete FWS)`);
|
||||||
|
|
||||||
assert("test@iana.org\u000D\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org\u000D\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no actual white space`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no actual white space`);
|
||||||
|
|
||||||
assert("test@iana.org\u000D\u000A \u000D\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org\u000D\u000A \u000D\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not obs-FWS because there must be white space on each "fold"`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not obs-FWS because there must be white space on each "fold"`);
|
||||||
|
|
||||||
assert("test@iana.org \u000D\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org \u000D\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the fold`);
|
||||||
|
|
||||||
assert("test@iana.org \u000D\u000A ".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org \u000D\u000A ".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.foldingWhitespace, `FWS`);
|
EmailStatusCode.foldingWhitespace, `FWS`);
|
||||||
|
|
||||||
assert("test@iana.org \u000D\u000A \u000D\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org \u000D\u000A \u000D\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the second fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrLfEnd, `Not FWS because no white space after the second fold`);
|
||||||
|
|
||||||
assert("test@iana.org \u000D\u000A\u000D\u000A".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org \u000D\u000A\u000D\u000A".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after either fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after either fold`);
|
||||||
|
|
||||||
assert("test@iana.org \u000D\u000A\u000D\u000A ".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("test@iana.org \u000D\u000A\u000D\u000A ".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after the first fold`);
|
EmailStatusCode.errorFoldingWhitespaceCrflX2, `Not FWS because no white space after the first fold`);
|
||||||
|
|
||||||
assert(" test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.foldingWhitespace);
|
assert(" test@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.foldingWhitespace);
|
||||||
assert(`test@iana.org `.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.foldingWhitespace);
|
assert(`test@iana.org `.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.foldingWhitespace);
|
||||||
|
|
||||||
assert(`test@[IPv6:1::2:]`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test@[IPv6:1::2:]`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.rfc5322IpV6ColonEnd);
|
EmailStatusCode.rfc5322IpV6ColonEnd);
|
||||||
|
|
||||||
assert("\"test\\\u00A9\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert("\"test\\\u00A9\"@iana.org".isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.errorExpectingQuotedPair);
|
EmailStatusCode.errorExpectingQuotedPair);
|
||||||
|
|
||||||
assert(`test@iana/icann.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322Domain);
|
assert(`test@iana/icann.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5322Domain);
|
||||||
|
|
||||||
assert(`test.(comment)test@iana.org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
assert(`test.(comment)test@iana.org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
EmailStatusCode.deprecatedComment);
|
EmailStatusCode.deprecatedComment);
|
||||||
|
|
||||||
assert(`test@org`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321TopLevelDomain);
|
assert(`test@org`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.rfc5321TopLevelDomain);
|
||||||
|
|
||||||
// assert(`test@test.com`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
|
// assert(`test@test.com`.isEmail(No.checkDns, EmailStatusCode.any).statusCode ==
|
||||||
//EmailStatusCode.dnsWarningNoMXRecord, `test.com has an A-record but not an MX-record`);
|
//EmailStatusCode.dnsWarningNoMXRecord, `test.com has an A-record but not an MX-record`);
|
||||||
// DNS check is currently not implemented
|
// DNS check is currently not implemented
|
||||||
//
|
//
|
||||||
// assert(`test@nic.no`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord,
|
// assert(`test@nic.no`.isEmail(No.checkDns, EmailStatusCode.any).statusCode == EmailStatusCode.dnsWarningNoRecord,
|
||||||
// `nic.no currently has no MX-records or A-records (Feb 2011). If you are seeing an A-record for nic.io then`
|
// `nic.no currently has no MX-records or A-records (Feb 2011). If you are seeing an A-record for nic.io then`
|
||||||
// ` try setting your DNS server to 8.8.8.8 (the Google DNS server) - your DNS server may be faking an A-record`
|
// ` try setting your DNS server to 8.8.8.8 (the Google DNS server) - your DNS server may be faking an A-record`
|
||||||
// ` (OpenDNS does this, for instance).`); // DNS check is currently not implemented
|
// ` (OpenDNS does this, for instance).`); // DNS check is currently not implemented
|
||||||
|
|
|
@ -2583,6 +2583,7 @@ private:
|
||||||
version(SlowTests)
|
version(SlowTests)
|
||||||
softUnittest({
|
softUnittest({
|
||||||
import std.datetime;
|
import std.datetime;
|
||||||
|
import std.typecons;
|
||||||
|
|
||||||
enum msecs = 1000;
|
enum msecs = 1000;
|
||||||
auto pair = socketPair();
|
auto pair = socketPair();
|
||||||
|
@ -2590,7 +2591,7 @@ private:
|
||||||
sock.setOption(SocketOptionLevel.SOCKET,
|
sock.setOption(SocketOptionLevel.SOCKET,
|
||||||
SocketOption.RCVTIMEO, dur!"msecs"(msecs));
|
SocketOption.RCVTIMEO, dur!"msecs"(msecs));
|
||||||
|
|
||||||
auto sw = StopWatch(AutoStart.yes);
|
auto sw = StopWatch(Yes.autoStart);
|
||||||
ubyte[1] buf;
|
ubyte[1] buf;
|
||||||
sock.receive(buf);
|
sock.receive(buf);
|
||||||
sw.stop();
|
sw.stop();
|
||||||
|
@ -3208,6 +3209,7 @@ public:
|
||||||
* Example:
|
* Example:
|
||||||
* ---
|
* ---
|
||||||
* import std.datetime;
|
* import std.datetime;
|
||||||
|
* import std.typecons;
|
||||||
* auto pair = socketPair();
|
* auto pair = socketPair();
|
||||||
* scope(exit) foreach (s; pair) s.close();
|
* scope(exit) foreach (s; pair) s.close();
|
||||||
*
|
*
|
||||||
|
@ -3216,7 +3218,7 @@ public:
|
||||||
* pair[0].setOption(SocketOptionLevel.SOCKET,
|
* pair[0].setOption(SocketOptionLevel.SOCKET,
|
||||||
* SocketOption.RCVTIMEO, dur!"seconds"(1));
|
* SocketOption.RCVTIMEO, dur!"seconds"(1));
|
||||||
*
|
*
|
||||||
* auto sw = StopWatch(AutoStart.yes);
|
* auto sw = StopWatch(Yes.autoStart);
|
||||||
* ubyte[1] buffer;
|
* ubyte[1] buffer;
|
||||||
* pair[0].receive(buffer);
|
* pair[0].receive(buffer);
|
||||||
* writefln("Waited %s ms until the socket timed out.",
|
* writefln("Waited %s ms until the socket timed out.",
|
||||||
|
|
18
std/stdio.d
18
std/stdio.d
|
@ -1897,7 +1897,7 @@ Allows to directly use range operations on lines of a file.
|
||||||
enum defTerm = cast(Terminator)"\n";
|
enum defTerm = cast(Terminator)"\n";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
this(File f, KeepTerminator kt = KeepTerminator.no,
|
this(File f, KeepTerminator kt = No.keepTerminator,
|
||||||
Terminator terminator = defTerm)
|
Terminator terminator = defTerm)
|
||||||
{
|
{
|
||||||
impl = PImpl(f, kt, terminator);
|
impl = PImpl(f, kt, terminator);
|
||||||
|
@ -1963,7 +1963,7 @@ Allows to directly use range operations on lines of a file.
|
||||||
file.detach();
|
file.detach();
|
||||||
line = null;
|
line = null;
|
||||||
}
|
}
|
||||||
else if (keepTerminator == KeepTerminator.no
|
else if (keepTerminator == No.keepTerminator
|
||||||
&& endsWith(line, terminator))
|
&& endsWith(line, terminator))
|
||||||
{
|
{
|
||||||
static if (isScalarType!Terminator)
|
static if (isScalarType!Terminator)
|
||||||
|
@ -1998,7 +1998,7 @@ instead.
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
Char = Character type for each line, defaulting to $(D char).
|
Char = Character type for each line, defaulting to $(D char).
|
||||||
keepTerminator = Use $(D KeepTerminator.yes) to include the
|
keepTerminator = Use $(D Yes.keepTerminator) to include the
|
||||||
terminator at the end of each line.
|
terminator at the end of each line.
|
||||||
terminator = Line separator ($(D '\n') by default). Use
|
terminator = Line separator ($(D '\n') by default). Use
|
||||||
$(REF newline, std,ascii) for portability (unless the file was opened in
|
$(REF newline, std,ascii) for portability (unless the file was opened in
|
||||||
|
@ -2043,7 +2043,7 @@ $(D front) after the corresponding $(D popFront) call is made (because
|
||||||
the contents may well have changed).
|
the contents may well have changed).
|
||||||
*/
|
*/
|
||||||
auto byLine(Terminator = char, Char = char)
|
auto byLine(Terminator = char, Char = char)
|
||||||
(KeepTerminator keepTerminator = KeepTerminator.no,
|
(KeepTerminator keepTerminator = No.keepTerminator,
|
||||||
Terminator terminator = '\n')
|
Terminator terminator = '\n')
|
||||||
if (isScalarType!Terminator)
|
if (isScalarType!Terminator)
|
||||||
{
|
{
|
||||||
|
@ -2157,7 +2157,7 @@ primitives may throw $(D StdioException) on I/O error.
|
||||||
|
|
||||||
Params:
|
Params:
|
||||||
Char = Character type for each line, defaulting to $(D immutable char).
|
Char = Character type for each line, defaulting to $(D immutable char).
|
||||||
keepTerminator = Use $(D KeepTerminator.yes) to include the
|
keepTerminator = Use $(D Yes.keepTerminator) to include the
|
||||||
terminator at the end of each line.
|
terminator at the end of each line.
|
||||||
terminator = Line separator ($(D '\n') by default). Use
|
terminator = Line separator ($(D '\n') by default). Use
|
||||||
$(REF newline, std,ascii) for portability (unless the file was opened in
|
$(REF newline, std,ascii) for portability (unless the file was opened in
|
||||||
|
@ -2181,7 +2181,7 @@ See_Also:
|
||||||
$(REF readText, std,file)
|
$(REF readText, std,file)
|
||||||
*/
|
*/
|
||||||
auto byLineCopy(Terminator = char, Char = immutable char)
|
auto byLineCopy(Terminator = char, Char = immutable char)
|
||||||
(KeepTerminator keepTerminator = KeepTerminator.no,
|
(KeepTerminator keepTerminator = No.keepTerminator,
|
||||||
Terminator terminator = '\n')
|
Terminator terminator = '\n')
|
||||||
if (isScalarType!Terminator)
|
if (isScalarType!Terminator)
|
||||||
{
|
{
|
||||||
|
@ -2260,7 +2260,7 @@ $(REF readText, std,file)
|
||||||
assert(File(deleteme).byLineCopy(kt, term).array.sort() == witness.dup.sort());
|
assert(File(deleteme).byLineCopy(kt, term).array.sort() == witness.dup.sort());
|
||||||
}
|
}
|
||||||
|
|
||||||
KeepTerminator kt = KeepTerminator.no;
|
KeepTerminator kt = No.keepTerminator;
|
||||||
test("", null, kt, '\n');
|
test("", null, kt, '\n');
|
||||||
test("\n", [ "" ], kt, '\n');
|
test("\n", [ "" ], kt, '\n');
|
||||||
test("asd\ndef\nasdf", [ "asd", "def", "asdf" ], kt, '\n');
|
test("asd\ndef\nasdf", [ "asd", "def", "asdf" ], kt, '\n');
|
||||||
|
@ -2271,7 +2271,7 @@ $(REF readText, std,file)
|
||||||
kt, "\r\n");
|
kt, "\r\n");
|
||||||
test("sue\r", ["sue"], kt, '\r');
|
test("sue\r", ["sue"], kt, '\r');
|
||||||
|
|
||||||
kt = KeepTerminator.yes;
|
kt = Yes.keepTerminator;
|
||||||
test("", null, kt, '\n');
|
test("", null, kt, '\n');
|
||||||
test("\n", [ "\n" ], kt, '\n');
|
test("\n", [ "\n" ], kt, '\n');
|
||||||
test("asd\ndef\nasdf", [ "asd\n", "def\n", "asdf" ], kt, '\n');
|
test("asd\ndef\nasdf", [ "asd\n", "def\n", "asdf" ], kt, '\n');
|
||||||
|
@ -4352,7 +4352,7 @@ __gshared
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
stdin // read from stdin
|
stdin // read from stdin
|
||||||
.byLineCopy(KeepTerminator.yes) // copying each line
|
.byLineCopy(Yes.keepTerminator) // copying each line
|
||||||
.array() // convert to array of lines
|
.array() // convert to array of lines
|
||||||
.sort() // sort the lines
|
.sort() // sort the lines
|
||||||
.copy( // copy output of .sort to an OutputRange
|
.copy( // copy output of .sort to an OutputRange
|
||||||
|
|
430
std/string.d
430
std/string.d
|
@ -187,7 +187,7 @@ private:
|
||||||
|
|
||||||
public import std.uni : icmp, toLower, toLowerInPlace, toUpper, toUpperInPlace;
|
public import std.uni : icmp, toLower, toLowerInPlace, toUpper, toUpperInPlace;
|
||||||
public import std.format : format, sformat;
|
public import std.format : format, sformat;
|
||||||
import std.typecons : Flag;
|
import std.typecons : Flag, Yes, No;
|
||||||
|
|
||||||
import std.meta; // AliasSeq, staticIndexOf
|
import std.meta; // AliasSeq, staticIndexOf
|
||||||
import std.range.primitives; // back, ElementEncodingType, ElementType, front,
|
import std.range.primitives; // back, ElementEncodingType, ElementType, front,
|
||||||
|
@ -364,7 +364,7 @@ alias CaseSensitive = Flag!"caseSensitive";
|
||||||
s = string or InputRange of characters to search in correct UTF format
|
s = string or InputRange of characters to search in correct UTF format
|
||||||
c = character to search for
|
c = character to search for
|
||||||
startIdx = starting index to a well-formed code point
|
startIdx = starting index to a well-formed code point
|
||||||
cs = CaseSensitive.yes or CaseSensitive.no
|
cs = $(D Yes.caseSensitive) or $(D No.caseSensitive)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
the index of the first occurrence of $(D c) in $(D s) with
|
the index of the first occurrence of $(D c) in $(D s) with
|
||||||
|
@ -381,7 +381,7 @@ alias CaseSensitive = Flag!"caseSensitive";
|
||||||
|
|
||||||
+/
|
+/
|
||||||
ptrdiff_t indexOf(Range)(Range s, in dchar c,
|
ptrdiff_t indexOf(Range)(Range s, in dchar c,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
||||||
!isConvertibleToString!Range)
|
!isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
|
@ -390,7 +390,7 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c,
|
||||||
import std.utf : byDchar, byCodeUnit, UTFException, codeLength;
|
import std.utf : byDchar, byCodeUnit, UTFException, codeLength;
|
||||||
alias Char = Unqual!(ElementEncodingType!Range);
|
alias Char = Unqual!(ElementEncodingType!Range);
|
||||||
|
|
||||||
if (cs == CaseSensitive.yes)
|
if (cs == Yes.caseSensitive)
|
||||||
{
|
{
|
||||||
static if (Char.sizeof == 1 && isSomeString!Range)
|
static if (Char.sizeof == 1 && isSomeString!Range)
|
||||||
{
|
{
|
||||||
|
@ -509,7 +509,7 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c,
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
|
ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
||||||
!isConvertibleToString!Range)
|
!isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
|
@ -548,7 +548,7 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(indexOf(s, 'W') == 6);
|
assert(indexOf(s, 'W') == 6);
|
||||||
assert(indexOf(s, 'Z') == -1);
|
assert(indexOf(s, 'Z') == -1);
|
||||||
assert(indexOf(s, 'w', CaseSensitive.no) == 6);
|
assert(indexOf(s, 'w', No.caseSensitive) == 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -557,18 +557,18 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(indexOf(s, 'W', 4) == 6);
|
assert(indexOf(s, 'W', 4) == 6);
|
||||||
assert(indexOf(s, 'Z', 100) == -1);
|
assert(indexOf(s, 'Z', 100) == -1);
|
||||||
assert(indexOf(s, 'w', 3, CaseSensitive.no) == 6);
|
assert(indexOf(s, 'w', 3, No.caseSensitive) == 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c,
|
ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (isConvertibleToString!Range)
|
if (isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
return indexOf!(StringTypeOf!Range)(s, c, cs);
|
return indexOf!(StringTypeOf!Range)(s, c, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (isConvertibleToString!Range)
|
if (isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
return indexOf!(StringTypeOf!Range)(s, c, startIdx, cs);
|
return indexOf!(StringTypeOf!Range)(s, c, startIdx, cs);
|
||||||
|
@ -596,16 +596,16 @@ ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
||||||
assert(indexOf(to!S("abba"), cast(dchar)'a') == 0);
|
assert(indexOf(to!S("abba"), cast(dchar)'a') == 0);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'f') == 2);
|
assert(indexOf(to!S("def"), cast(dchar)'f') == 2);
|
||||||
|
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'a', CaseSensitive.no) == -1);
|
assert(indexOf(to!S("def"), cast(dchar)'a', No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'a', CaseSensitive.no) == -1);
|
assert(indexOf(to!S("def"), cast(dchar)'a', No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("Abba"), cast(dchar)'a', CaseSensitive.no) == 0);
|
assert(indexOf(to!S("Abba"), cast(dchar)'a', No.caseSensitive) == 0);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'F', CaseSensitive.no) == 2);
|
assert(indexOf(to!S("def"), cast(dchar)'F', No.caseSensitive) == 2);
|
||||||
assert(indexOf(to!S("ödef"), 'ö', CaseSensitive.no) == 0);
|
assert(indexOf(to!S("ödef"), 'ö', No.caseSensitive) == 0);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
assert(indexOf("def", cast(char)'f', CaseSensitive.no) == 2);
|
assert(indexOf("def", cast(char)'f', No.caseSensitive) == 2);
|
||||||
assert(indexOf(sPlts, cast(char)'P', CaseSensitive.no) == 23);
|
assert(indexOf(sPlts, cast(char)'P', No.caseSensitive) == 23);
|
||||||
assert(indexOf(sPlts, cast(char)'R', CaseSensitive.no) == 2);
|
assert(indexOf(sPlts, cast(char)'R', No.caseSensitive) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -655,21 +655,21 @@ ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'f', 1) == 2);
|
assert(indexOf(to!S("def"), cast(dchar)'f', 1) == 2);
|
||||||
|
|
||||||
assert((to!S("def")).indexOf(cast(dchar)'a', 1,
|
assert((to!S("def")).indexOf(cast(dchar)'a', 1,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'a', 1,
|
assert(indexOf(to!S("def"), cast(dchar)'a', 1,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'a', 12,
|
assert(indexOf(to!S("def"), cast(dchar)'a', 12,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("AbbA"), cast(dchar)'a', 2,
|
assert(indexOf(to!S("AbbA"), cast(dchar)'a', 2,
|
||||||
CaseSensitive.no) == 3);
|
No.caseSensitive) == 3);
|
||||||
assert(indexOf(to!S("def"), cast(dchar)'F', 2, CaseSensitive.no) == 2);
|
assert(indexOf(to!S("def"), cast(dchar)'F', 2, No.caseSensitive) == 2);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
assert(indexOf("def", cast(char)'f', cast(uint)2,
|
assert(indexOf("def", cast(char)'f', cast(uint)2,
|
||||||
CaseSensitive.no) == 2);
|
No.caseSensitive) == 2);
|
||||||
assert(indexOf(sPlts, cast(char)'P', 12, CaseSensitive.no) == 23);
|
assert(indexOf(sPlts, cast(char)'P', 12, No.caseSensitive) == 23);
|
||||||
assert(indexOf(sPlts, cast(char)'R', cast(ulong)1,
|
assert(indexOf(sPlts, cast(char)'R', cast(ulong)1,
|
||||||
CaseSensitive.no) == 2);
|
No.caseSensitive) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -690,7 +690,7 @@ ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
||||||
s = string or ForwardRange of characters to search in correct UTF format
|
s = string or ForwardRange of characters to search in correct UTF format
|
||||||
sub = substring to search for
|
sub = substring to search for
|
||||||
startIdx = the index into s to start searching from
|
startIdx = the index into s to start searching from
|
||||||
cs = CaseSensitive.yes or CaseSensitive.no
|
cs = $(D Yes.caseSensitive) or $(D No.caseSensitive)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
the index of the first occurrence of $(D sub) in $(D s) with
|
the index of the first occurrence of $(D sub) in $(D s) with
|
||||||
|
@ -710,7 +710,7 @@ ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx,
|
||||||
tolower and toupper is not 1:1.
|
tolower and toupper is not 1:1.
|
||||||
+/
|
+/
|
||||||
ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
||||||
isSomeChar!Char)
|
isSomeChar!Char)
|
||||||
{
|
{
|
||||||
|
@ -721,7 +721,7 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
import std.algorithm.searching : find;
|
import std.algorithm.searching : find;
|
||||||
|
|
||||||
const(Char1)[] balance;
|
const(Char1)[] balance;
|
||||||
if (cs == CaseSensitive.yes)
|
if (cs == Yes.caseSensitive)
|
||||||
{
|
{
|
||||||
balance = find(s, sub);
|
balance = find(s, sub);
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
if (subr.empty)
|
if (subr.empty)
|
||||||
return indexOf(s, sub0, cs);
|
return indexOf(s, sub0, cs);
|
||||||
|
|
||||||
if (cs == CaseSensitive.no)
|
if (cs == No.caseSensitive)
|
||||||
sub0 = toLower(sub0);
|
sub0 = toLower(sub0);
|
||||||
|
|
||||||
/* Classic double nested loop search algorithm
|
/* Classic double nested loop search algorithm
|
||||||
|
@ -758,7 +758,7 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
for (auto sbydchar = s.byDchar(); !sbydchar.empty; sbydchar.popFront())
|
for (auto sbydchar = s.byDchar(); !sbydchar.empty; sbydchar.popFront())
|
||||||
{
|
{
|
||||||
dchar c2 = sbydchar.front;
|
dchar c2 = sbydchar.front;
|
||||||
if (cs == CaseSensitive.no)
|
if (cs == No.caseSensitive)
|
||||||
c2 = toLower(c2);
|
c2 = toLower(c2);
|
||||||
if (c2 == sub0)
|
if (c2 == sub0)
|
||||||
{
|
{
|
||||||
|
@ -768,7 +768,7 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
s2.popFront();
|
s2.popFront();
|
||||||
if (s2.empty)
|
if (s2.empty)
|
||||||
return -1;
|
return -1;
|
||||||
if (cs == CaseSensitive.yes ? c != s2.front
|
if (cs == Yes.caseSensitive ? c != s2.front
|
||||||
: toLower(c) != toLower(s2.front)
|
: toLower(c) != toLower(s2.front)
|
||||||
)
|
)
|
||||||
goto Lnext;
|
goto Lnext;
|
||||||
|
@ -784,7 +784,7 @@ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub,
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes)
|
in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe if (isSomeChar!Char1 && isSomeChar!Char2)
|
@safe if (isSomeChar!Char1 && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
if (startIdx < s.length)
|
if (startIdx < s.length)
|
||||||
|
@ -804,7 +804,7 @@ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(indexOf(s, "Wo", 4) == 6);
|
assert(indexOf(s, "Wo", 4) == 6);
|
||||||
assert(indexOf(s, "Zo", 100) == -1);
|
assert(indexOf(s, "Zo", 100) == -1);
|
||||||
assert(indexOf(s, "wo", 3, CaseSensitive.no) == 6);
|
assert(indexOf(s, "wo", 3, No.caseSensitive) == 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -813,11 +813,11 @@ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(indexOf(s, "Wo") == 6);
|
assert(indexOf(s, "Wo") == 6);
|
||||||
assert(indexOf(s, "Zo") == -1);
|
assert(indexOf(s, "Zo") == -1);
|
||||||
assert(indexOf(s, "wO", CaseSensitive.no) == 6);
|
assert(indexOf(s, "wO", No.caseSensitive) == 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptrdiff_t indexOf(Range, Char)(auto ref Range s, const(Char)[] sub,
|
ptrdiff_t indexOf(Range, Char)(auto ref Range s, const(Char)[] sub,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
||||||
isSomeChar!Char) &&
|
isSomeChar!Char) &&
|
||||||
is(StringTypeOf!Range))
|
is(StringTypeOf!Range))
|
||||||
|
@ -850,28 +850,28 @@ ptrdiff_t indexOf(Range, Char)(auto ref Range s, const(Char)[] sub,
|
||||||
assert(indexOf(to!S("dfefffg"), to!T("fff")) == 3);
|
assert(indexOf(to!S("dfefffg"), to!T("fff")) == 3);
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("fff")) == 6);
|
assert(indexOf(to!S("dfeffgfff"), to!T("fff")) == 6);
|
||||||
|
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("a"), CaseSensitive.no) == -1);
|
assert(indexOf(to!S("dfeffgfff"), to!T("a"), No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("def"), to!T("a"), CaseSensitive.no) == -1);
|
assert(indexOf(to!S("def"), to!T("a"), No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("abba"), to!T("a"), CaseSensitive.no) == 0);
|
assert(indexOf(to!S("abba"), to!T("a"), No.caseSensitive) == 0);
|
||||||
assert(indexOf(to!S("def"), to!T("f"), CaseSensitive.no) == 2);
|
assert(indexOf(to!S("def"), to!T("f"), No.caseSensitive) == 2);
|
||||||
assert(indexOf(to!S("dfefffg"), to!T("fff"), CaseSensitive.no) == 3);
|
assert(indexOf(to!S("dfefffg"), to!T("fff"), No.caseSensitive) == 3);
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), CaseSensitive.no) == 6);
|
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), No.caseSensitive) == 6);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
||||||
|
|
||||||
assert(indexOf(sMars, to!T("MY fAVe"), CaseSensitive.no) == -1);
|
assert(indexOf(sMars, to!T("MY fAVe"), No.caseSensitive) == -1);
|
||||||
assert(indexOf(sMars, to!T("mY fAVOriTe"), CaseSensitive.no) == 7);
|
assert(indexOf(sMars, to!T("mY fAVOriTe"), No.caseSensitive) == 7);
|
||||||
assert(indexOf(sPlts, to!T("mArS:"), CaseSensitive.no) == 0);
|
assert(indexOf(sPlts, to!T("mArS:"), No.caseSensitive) == 0);
|
||||||
assert(indexOf(sPlts, to!T("rOcK"), CaseSensitive.no) == 17);
|
assert(indexOf(sPlts, to!T("rOcK"), No.caseSensitive) == 17);
|
||||||
assert(indexOf(sPlts, to!T("Un."), CaseSensitive.no) == 41);
|
assert(indexOf(sPlts, to!T("Un."), No.caseSensitive) == 41);
|
||||||
assert(indexOf(sPlts, to!T(sPlts), CaseSensitive.no) == 0);
|
assert(indexOf(sPlts, to!T(sPlts), No.caseSensitive) == 0);
|
||||||
|
|
||||||
assert(indexOf("\u0100", to!T("\u0100"), CaseSensitive.no) == 0);
|
assert(indexOf("\u0100", to!T("\u0100"), No.caseSensitive) == 0);
|
||||||
|
|
||||||
// Thanks to Carlos Santander B. and zwang
|
// Thanks to Carlos Santander B. and zwang
|
||||||
assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y",
|
assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y",
|
||||||
to!T("page-break-before"), CaseSensitive.no) == -1);
|
to!T("page-break-before"), No.caseSensitive) == -1);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -919,32 +919,32 @@ unittest
|
||||||
assert(indexOf(to!S("dfefffg"), to!T("fff"), 1) == 3);
|
assert(indexOf(to!S("dfefffg"), to!T("fff"), 1) == 3);
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 5) == 6);
|
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 5) == 6);
|
||||||
|
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("a"), 1, CaseSensitive.no) == -1);
|
assert(indexOf(to!S("dfeffgfff"), to!T("a"), 1, No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("def"), to!T("a"), 2, CaseSensitive.no) == -1);
|
assert(indexOf(to!S("def"), to!T("a"), 2, No.caseSensitive) == -1);
|
||||||
assert(indexOf(to!S("abba"), to!T("a"), 3, CaseSensitive.no) == 3);
|
assert(indexOf(to!S("abba"), to!T("a"), 3, No.caseSensitive) == 3);
|
||||||
assert(indexOf(to!S("def"), to!T("f"), 1, CaseSensitive.no) == 2);
|
assert(indexOf(to!S("def"), to!T("f"), 1, No.caseSensitive) == 2);
|
||||||
assert(indexOf(to!S("dfefffg"), to!T("fff"), 2, CaseSensitive.no) == 3);
|
assert(indexOf(to!S("dfefffg"), to!T("fff"), 2, No.caseSensitive) == 3);
|
||||||
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 4, CaseSensitive.no) == 6);
|
assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 4, No.caseSensitive) == 6);
|
||||||
assert(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, CaseSensitive.no) == 9,
|
assert(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, No.caseSensitive) == 9,
|
||||||
to!string(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, CaseSensitive.no))
|
to!string(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, No.caseSensitive))
|
||||||
~ " " ~ S.stringof ~ " " ~ T.stringof);
|
~ " " ~ S.stringof ~ " " ~ T.stringof);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
||||||
|
|
||||||
assert(indexOf(sMars, to!T("MY fAVe"), 10,
|
assert(indexOf(sMars, to!T("MY fAVe"), 10,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOf(sMars, to!T("mY fAVOriTe"), 4, CaseSensitive.no) == 7);
|
assert(indexOf(sMars, to!T("mY fAVOriTe"), 4, No.caseSensitive) == 7);
|
||||||
assert(indexOf(sPlts, to!T("mArS:"), 0, CaseSensitive.no) == 0);
|
assert(indexOf(sPlts, to!T("mArS:"), 0, No.caseSensitive) == 0);
|
||||||
assert(indexOf(sPlts, to!T("rOcK"), 12, CaseSensitive.no) == 17);
|
assert(indexOf(sPlts, to!T("rOcK"), 12, No.caseSensitive) == 17);
|
||||||
assert(indexOf(sPlts, to!T("Un."), 32, CaseSensitive.no) == 41);
|
assert(indexOf(sPlts, to!T("Un."), 32, No.caseSensitive) == 41);
|
||||||
assert(indexOf(sPlts, to!T(sPlts), 0, CaseSensitive.no) == 0);
|
assert(indexOf(sPlts, to!T(sPlts), 0, No.caseSensitive) == 0);
|
||||||
|
|
||||||
assert(indexOf("\u0100", to!T("\u0100"), 0, CaseSensitive.no) == 0);
|
assert(indexOf("\u0100", to!T("\u0100"), 0, No.caseSensitive) == 0);
|
||||||
|
|
||||||
// Thanks to Carlos Santander B. and zwang
|
// Thanks to Carlos Santander B. and zwang
|
||||||
assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y",
|
assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y",
|
||||||
to!T("page-break-before"), 10, CaseSensitive.no) == -1);
|
to!T("page-break-before"), 10, No.caseSensitive) == -1);
|
||||||
|
|
||||||
// In order for indexOf with and without index to be consistent
|
// In order for indexOf with and without index to be consistent
|
||||||
assert(indexOf(to!S(""), to!T("")) == indexOf(to!S(""), to!T(""), 0));
|
assert(indexOf(to!S(""), to!T("")) == indexOf(to!S(""), to!T(""), 0));
|
||||||
|
@ -967,7 +967,7 @@ unittest
|
||||||
s = string to search
|
s = string to search
|
||||||
c = character to search for
|
c = character to search for
|
||||||
startIdx = the index into s to start searching from
|
startIdx = the index into s to start searching from
|
||||||
cs = CaseSensitive.yes or CaseSensitive.no
|
cs = $(D Yes.caseSensitive) or $(D No.caseSensitive)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The index of the last occurrence of $(D c) in $(D s). If $(D c) is not
|
The index of the last occurrence of $(D c) in $(D s). If $(D c) is not
|
||||||
|
@ -982,12 +982,12 @@ unittest
|
||||||
$(D cs) indicates whether the comparisons are case sensitive.
|
$(D cs) indicates whether the comparisons are case sensitive.
|
||||||
+/
|
+/
|
||||||
ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c,
|
ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char)
|
if (isSomeChar!Char)
|
||||||
{
|
{
|
||||||
static import std.ascii, std.uni;
|
static import std.ascii, std.uni;
|
||||||
import std.utf : canSearchInCodeUnits;
|
import std.utf : canSearchInCodeUnits;
|
||||||
if (cs == CaseSensitive.yes)
|
if (cs == Yes.caseSensitive)
|
||||||
{
|
{
|
||||||
if (canSearchInCodeUnits!Char(c))
|
if (canSearchInCodeUnits!Char(c))
|
||||||
{
|
{
|
||||||
|
@ -1045,7 +1045,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c,
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char)
|
if (isSomeChar!Char)
|
||||||
{
|
{
|
||||||
if (startIdx <= s.length)
|
if (startIdx <= s.length)
|
||||||
|
@ -1062,7 +1062,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(lastIndexOf(s, 'l') == 9);
|
assert(lastIndexOf(s, 'l') == 9);
|
||||||
assert(lastIndexOf(s, 'Z') == -1);
|
assert(lastIndexOf(s, 'Z') == -1);
|
||||||
assert(lastIndexOf(s, 'L', CaseSensitive.no) == 9);
|
assert(lastIndexOf(s, 'L', No.caseSensitive) == 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -1071,7 +1071,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(lastIndexOf(s, 'l', 4) == 3);
|
assert(lastIndexOf(s, 'l', 4) == 3);
|
||||||
assert(lastIndexOf(s, 'Z', 1337) == -1);
|
assert(lastIndexOf(s, 'Z', 1337) == -1);
|
||||||
assert(lastIndexOf(s, 'L', 7, CaseSensitive.no) == 3);
|
assert(lastIndexOf(s, 'L', 7, No.caseSensitive) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe pure unittest
|
@safe pure unittest
|
||||||
|
@ -1091,19 +1091,19 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
assert(lastIndexOf(to!S("def"), 'f') == 2);
|
assert(lastIndexOf(to!S("def"), 'f') == 2);
|
||||||
assert(lastIndexOf(to!S("ödef"), 'ö') == 0);
|
assert(lastIndexOf(to!S("ödef"), 'ö') == 0);
|
||||||
|
|
||||||
assert(lastIndexOf(cast(S) null, 'a', CaseSensitive.no) == -1);
|
assert(lastIndexOf(cast(S) null, 'a', No.caseSensitive) == -1);
|
||||||
assert(lastIndexOf(to!S("def"), 'a', CaseSensitive.no) == -1);
|
assert(lastIndexOf(to!S("def"), 'a', No.caseSensitive) == -1);
|
||||||
assert(lastIndexOf(to!S("AbbA"), 'a', CaseSensitive.no) == 3);
|
assert(lastIndexOf(to!S("AbbA"), 'a', No.caseSensitive) == 3);
|
||||||
assert(lastIndexOf(to!S("def"), 'F', CaseSensitive.no) == 2);
|
assert(lastIndexOf(to!S("def"), 'F', No.caseSensitive) == 2);
|
||||||
assert(lastIndexOf(to!S("ödef"), 'ö', CaseSensitive.no) == 0);
|
assert(lastIndexOf(to!S("ödef"), 'ö', No.caseSensitive) == 0);
|
||||||
assert(lastIndexOf(to!S("i\u0100def"), to!dchar("\u0100"),
|
assert(lastIndexOf(to!S("i\u0100def"), to!dchar("\u0100"),
|
||||||
CaseSensitive.no) == 1);
|
No.caseSensitive) == 1);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
|
|
||||||
assert(lastIndexOf(to!S("def"), 'f', CaseSensitive.no) == 2);
|
assert(lastIndexOf(to!S("def"), 'f', No.caseSensitive) == 2);
|
||||||
assert(lastIndexOf(sPlts, 'M', CaseSensitive.no) == 34);
|
assert(lastIndexOf(sPlts, 'M', No.caseSensitive) == 34);
|
||||||
assert(lastIndexOf(sPlts, 'S', CaseSensitive.no) == 40);
|
assert(lastIndexOf(sPlts, 'S', No.caseSensitive) == 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -1129,17 +1129,17 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
assert(lastIndexOf(to!S("abba"), 'a', 3) == 0);
|
assert(lastIndexOf(to!S("abba"), 'a', 3) == 0);
|
||||||
assert(lastIndexOf(to!S("deff"), 'f', 3) == 2);
|
assert(lastIndexOf(to!S("deff"), 'f', 3) == 2);
|
||||||
|
|
||||||
assert(lastIndexOf(cast(S) null, 'a', CaseSensitive.no) == -1);
|
assert(lastIndexOf(cast(S) null, 'a', No.caseSensitive) == -1);
|
||||||
assert(lastIndexOf(to!S("def"), 'a', CaseSensitive.no) == -1);
|
assert(lastIndexOf(to!S("def"), 'a', No.caseSensitive) == -1);
|
||||||
assert(lastIndexOf(to!S("AbbAa"), 'a', to!ushort(4), CaseSensitive.no) == 3,
|
assert(lastIndexOf(to!S("AbbAa"), 'a', to!ushort(4), No.caseSensitive) == 3,
|
||||||
to!string(lastIndexOf(to!S("AbbAa"), 'a', 4, CaseSensitive.no)));
|
to!string(lastIndexOf(to!S("AbbAa"), 'a', 4, No.caseSensitive)));
|
||||||
assert(lastIndexOf(to!S("def"), 'F', 3, CaseSensitive.no) == 2);
|
assert(lastIndexOf(to!S("def"), 'F', 3, No.caseSensitive) == 2);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
|
|
||||||
assert(lastIndexOf(to!S("def"), 'f', 4, CaseSensitive.no) == -1);
|
assert(lastIndexOf(to!S("def"), 'f', 4, No.caseSensitive) == -1);
|
||||||
assert(lastIndexOf(sPlts, 'M', sPlts.length -2, CaseSensitive.no) == 34);
|
assert(lastIndexOf(sPlts, 'M', sPlts.length -2, No.caseSensitive) == 34);
|
||||||
assert(lastIndexOf(sPlts, 'S', sPlts.length -2, CaseSensitive.no) == 40);
|
assert(lastIndexOf(sPlts, 'S', sPlts.length -2, No.caseSensitive) == 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -1155,7 +1155,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
s = string to search
|
s = string to search
|
||||||
sub = substring to search for
|
sub = substring to search for
|
||||||
startIdx = the index into s to start searching from
|
startIdx = the index into s to start searching from
|
||||||
cs = CaseSensitive.yes or CaseSensitive.no
|
cs = $(D Yes.caseSensitive) or $(D No.caseSensitive)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
the index of the last occurrence of $(D sub) in $(D s). If $(D sub) is
|
the index of the last occurrence of $(D sub) in $(D s). If $(D sub) is
|
||||||
|
@ -1170,7 +1170,7 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
|
||||||
$(D cs) indicates whether the comparisons are case sensitive.
|
$(D cs) indicates whether the comparisons are case sensitive.
|
||||||
+/
|
+/
|
||||||
ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char1 && isSomeChar!Char2)
|
if (isSomeChar!Char1 && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
import std.algorithm.searching : endsWith;
|
import std.algorithm.searching : endsWith;
|
||||||
|
@ -1184,7 +1184,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
if (walkLength(sub) == 1)
|
if (walkLength(sub) == 1)
|
||||||
return lastIndexOf(s, sub.front, cs);
|
return lastIndexOf(s, sub.front, cs);
|
||||||
|
|
||||||
if (cs == CaseSensitive.yes)
|
if (cs == Yes.caseSensitive)
|
||||||
{
|
{
|
||||||
static if (is(Unqual!Char1 == Unqual!Char2))
|
static if (is(Unqual!Char1 == Unqual!Char2))
|
||||||
{
|
{
|
||||||
|
@ -1250,7 +1250,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char1 && isSomeChar!Char2)
|
if (isSomeChar!Char1 && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
if (startIdx <= s.length)
|
if (startIdx <= s.length)
|
||||||
|
@ -1267,7 +1267,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(lastIndexOf(s, "ll") == 2);
|
assert(lastIndexOf(s, "ll") == 2);
|
||||||
assert(lastIndexOf(s, "Zo") == -1);
|
assert(lastIndexOf(s, "Zo") == -1);
|
||||||
assert(lastIndexOf(s, "lL", CaseSensitive.no) == 2);
|
assert(lastIndexOf(s, "lL", No.caseSensitive) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -1276,7 +1276,7 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
string s = "Hello World";
|
string s = "Hello World";
|
||||||
assert(lastIndexOf(s, "ll", 4) == 2);
|
assert(lastIndexOf(s, "ll", 4) == 2);
|
||||||
assert(lastIndexOf(s, "Zo", 128) == -1);
|
assert(lastIndexOf(s, "Zo", 128) == -1);
|
||||||
assert(lastIndexOf(s, "lL", 3, CaseSensitive.no) == -1);
|
assert(lastIndexOf(s, "lL", 3, No.caseSensitive) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe pure unittest
|
@safe pure unittest
|
||||||
|
@ -1323,27 +1323,27 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("")) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("")) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö")) == 0, typeStr);
|
assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö")) == 0, typeStr);
|
||||||
|
|
||||||
assert(lastIndexOf(cast(S)null, to!T("a"), CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(cast(S)null, to!T("a"), No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), CaseSensitive.no) == 6, typeStr);
|
assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), CaseSensitive.no) == 6, typeStr);
|
assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"), CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"), No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("xy"), CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("xy"), No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö"), CaseSensitive.no) == 0, typeStr);
|
assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö"), No.caseSensitive) == 0, typeStr);
|
||||||
|
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), CaseSensitive.no) == 6, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), CaseSensitive.no) == 6, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), CaseSensitive.no) == 7, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), No.caseSensitive) == 7, typeStr);
|
||||||
|
|
||||||
assert(lastIndexOf(to!S("ödfeffgfff"), to!T("ö"), CaseSensitive.yes) == 0);
|
assert(lastIndexOf(to!S("ödfeffgfff"), to!T("ö"), Yes.caseSensitive) == 0);
|
||||||
|
|
||||||
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
S sPlts = "Mars: the fourth Rock (Planet) from the Sun.";
|
||||||
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
S sMars = "Who\'s \'My Favorite Maritian?\'";
|
||||||
|
|
||||||
assert(lastIndexOf(sMars, to!T("RiTE maR"), CaseSensitive.no) == 14, typeStr);
|
assert(lastIndexOf(sMars, to!T("RiTE maR"), No.caseSensitive) == 14, typeStr);
|
||||||
assert(lastIndexOf(sPlts, to!T("FOuRTh"), CaseSensitive.no) == 10, typeStr);
|
assert(lastIndexOf(sPlts, to!T("FOuRTh"), No.caseSensitive) == 10, typeStr);
|
||||||
assert(lastIndexOf(sMars, to!T("whO\'s \'MY"), CaseSensitive.no) == 0, typeStr);
|
assert(lastIndexOf(sMars, to!T("whO\'s \'MY"), No.caseSensitive) == 0, typeStr);
|
||||||
assert(lastIndexOf(sMars, to!T(sMars), CaseSensitive.no) == 0, typeStr);
|
assert(lastIndexOf(sMars, to!T(sMars), No.caseSensitive) == 0, typeStr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -1401,17 +1401,17 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
assert(lastIndexOf(to!S("öafö"), to!T("ö"), 3) == 0, typeStr ~
|
assert(lastIndexOf(to!S("öafö"), to!T("ö"), 3) == 0, typeStr ~
|
||||||
to!string(lastIndexOf(to!S("öafö"), to!T("ö"), 3))); //BUG 10472
|
to!string(lastIndexOf(to!S("öafö"), to!T("ö"), 3))); //BUG 10472
|
||||||
|
|
||||||
assert(lastIndexOf(cast(S)null, to!T("a"), 1, CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(cast(S)null, to!T("a"), 1, No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), 5, CaseSensitive.no) == 2, typeStr);
|
assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), 5, No.caseSensitive) == 2, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 4, CaseSensitive.no) == 2, typeStr ~
|
assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 4, No.caseSensitive) == 2, typeStr ~
|
||||||
" " ~ to!string(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 3, CaseSensitive.no)));
|
" " ~ to!string(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 3, No.caseSensitive)));
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"),3 , CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"),3 , No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdefXY"), to!T("xy"), 4, CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdefXY"), to!T("xy"), 4, No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), 7, CaseSensitive.no) == -1, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), 7, No.caseSensitive) == -1, typeStr);
|
||||||
|
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), 4, CaseSensitive.no) == 2, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), 4, No.caseSensitive) == 2, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), 4, CaseSensitive.no) == 2, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), 4, No.caseSensitive) == 2, typeStr);
|
||||||
assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), 6, CaseSensitive.no) == 3, typeStr);
|
assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), 6, No.caseSensitive) == 3, typeStr);
|
||||||
assert(lastIndexOf(to!S(""), to!T(""), 0) == lastIndexOf(to!S(""), to!T("")), typeStr);
|
assert(lastIndexOf(to!S(""), to!T(""), 0) == lastIndexOf(to!S(""), to!T("")), typeStr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
@ -1428,11 +1428,11 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
|
||||||
|
|
||||||
private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
|
private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
|
||||||
const(Char)[] haystack, const(Char2)[] needles,
|
const(Char)[] haystack, const(Char2)[] needles,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
import std.algorithm.searching : canFind, findAmong;
|
import std.algorithm.searching : canFind, findAmong;
|
||||||
if (cs == CaseSensitive.yes)
|
if (cs == Yes.caseSensitive)
|
||||||
{
|
{
|
||||||
static if (forward)
|
static if (forward)
|
||||||
{
|
{
|
||||||
|
@ -1560,7 +1560,7 @@ private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)(
|
||||||
cs = Indicates whether the comparisons are case sensitive.
|
cs = Indicates whether the comparisons are case sensitive.
|
||||||
*/
|
*/
|
||||||
ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
return indexOfAnyNeitherImpl!(true, true)(haystack, needles, cs);
|
return indexOfAnyNeitherImpl!(true, true)(haystack, needles, cs);
|
||||||
|
@ -1568,7 +1568,7 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in size_t startIdx, in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
if (startIdx < haystack.length)
|
if (startIdx < haystack.length)
|
||||||
|
@ -1644,20 +1644,20 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("feg")) == 1);
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("feg")) == 1);
|
||||||
|
|
||||||
assert(indexOfAny(to!S("zfeffgfff"), to!T("ACDC"),
|
assert(indexOfAny(to!S("zfeffgfff"), to!T("ACDC"),
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfAny(to!S("def"), to!T("MI6"),
|
assert(indexOfAny(to!S("def"), to!T("MI6"),
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfAny(to!S("abba"), to!T("DEA"),
|
assert(indexOfAny(to!S("abba"), to!T("DEA"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
assert(indexOfAny(to!S("def"), to!T("FBI"), CaseSensitive.no) == 2);
|
assert(indexOfAny(to!S("def"), to!T("FBI"), No.caseSensitive) == 2);
|
||||||
assert(indexOfAny(to!S("dfefffg"), to!T("NSA"), CaseSensitive.no)
|
assert(indexOfAny(to!S("dfefffg"), to!T("NSA"), No.caseSensitive)
|
||||||
== -1);
|
== -1);
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("BND"),
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("BND"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"),
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
|
|
||||||
assert(indexOfAny("\u0100", to!T("\u0100"), CaseSensitive.no) == 0);
|
assert(indexOfAny("\u0100", to!T("\u0100"), No.caseSensitive) == 0);
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1683,22 +1683,22 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("fsb"), 5) == 6);
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("fsb"), 5) == 6);
|
||||||
|
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("NDS"), 1,
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("NDS"), 1,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfAny(to!S("def"), to!T("DRS"), 2,
|
assert(indexOfAny(to!S("def"), to!T("DRS"), 2,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfAny(to!S("abba"), to!T("SI"), 3,
|
assert(indexOfAny(to!S("abba"), to!T("SI"), 3,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfAny(to!S("deO"), to!T("ASIO"), 1,
|
assert(indexOfAny(to!S("deO"), to!T("ASIO"), 1,
|
||||||
CaseSensitive.no) == 2);
|
No.caseSensitive) == 2);
|
||||||
assert(indexOfAny(to!S("dfefffg"), to!T("fbh"), 2,
|
assert(indexOfAny(to!S("dfefffg"), to!T("fbh"), 2,
|
||||||
CaseSensitive.no) == 3);
|
No.caseSensitive) == 3);
|
||||||
assert(indexOfAny(to!S("dfeffgfff"), to!T("fEe"), 4,
|
assert(indexOfAny(to!S("dfeffgfff"), to!T("fEe"), 4,
|
||||||
CaseSensitive.no) == 4);
|
No.caseSensitive) == 4);
|
||||||
assert(indexOfAny(to!S("dfeffgffföä"), to!T("föä"), 9,
|
assert(indexOfAny(to!S("dfeffgffföä"), to!T("föä"), 9,
|
||||||
CaseSensitive.no) == 9);
|
No.caseSensitive) == 9);
|
||||||
|
|
||||||
assert(indexOfAny("\u0100", to!T("\u0100"), 0,
|
assert(indexOfAny("\u0100", to!T("\u0100"), 0,
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
foreach (cs; EnumMembers!CaseSensitive)
|
foreach (cs; EnumMembers!CaseSensitive)
|
||||||
|
@ -1731,7 +1731,7 @@ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles,
|
||||||
cs = Indicates whether the comparisons are case sensitive.
|
cs = Indicates whether the comparisons are case sensitive.
|
||||||
*/
|
*/
|
||||||
ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes)
|
const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe pure
|
@safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
|
@ -1741,7 +1741,7 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in size_t stopIdx,
|
const(Char2)[] needles, in size_t stopIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes) @safe pure
|
in CaseSensitive cs = Yes.caseSensitive) @safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
if (stopIdx <= haystack.length)
|
if (stopIdx <= haystack.length)
|
||||||
|
@ -1820,15 +1820,15 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
||||||
|
|
||||||
assert(lastIndexOfAny(to!S("zfeffgfff"), to!T("ACDC"),
|
assert(lastIndexOfAny(to!S("zfeffgfff"), to!T("ACDC"),
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(lastIndexOfAny(to!S("def"), to!T("MI6"),
|
assert(lastIndexOfAny(to!S("def"), to!T("MI6"),
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(lastIndexOfAny(to!S("abba"), to!T("DEA"),
|
assert(lastIndexOfAny(to!S("abba"), to!T("DEA"),
|
||||||
CaseSensitive.no) == 3);
|
No.caseSensitive) == 3);
|
||||||
assert(lastIndexOfAny(to!S("def"), to!T("FBI"),
|
assert(lastIndexOfAny(to!S("def"), to!T("FBI"),
|
||||||
CaseSensitive.no) == 2);
|
No.caseSensitive) == 2);
|
||||||
assert(lastIndexOfAny(to!S("dfefffg"), to!T("NSA"),
|
assert(lastIndexOfAny(to!S("dfefffg"), to!T("NSA"),
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
|
|
||||||
oeIdx = 2;
|
oeIdx = 2;
|
||||||
if (is(S == wstring) || is(S == dstring))
|
if (is(S == wstring) || is(S == dstring))
|
||||||
|
@ -1836,10 +1836,10 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
oeIdx = 1;
|
oeIdx = 1;
|
||||||
}
|
}
|
||||||
assert(lastIndexOfAny(to!S("ödfeffgfff"), to!T("BND"),
|
assert(lastIndexOfAny(to!S("ödfeffgfff"), to!T("BND"),
|
||||||
CaseSensitive.no) == oeIdx);
|
No.caseSensitive) == oeIdx);
|
||||||
|
|
||||||
assert(lastIndexOfAny("\u0100", to!T("\u0100"),
|
assert(lastIndexOfAny("\u0100", to!T("\u0100"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1879,21 +1879,21 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
typeStr);
|
typeStr);
|
||||||
|
|
||||||
assert(lastIndexOfAny(cast(S)null, to!T("a"), 1337,
|
assert(lastIndexOfAny(cast(S)null, to!T("a"), 1337,
|
||||||
CaseSensitive.no) == -1, typeStr);
|
No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("C"), 7,
|
assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("C"), 7,
|
||||||
CaseSensitive.no) == 6, typeStr);
|
No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("cd"), 5,
|
assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("cd"), 5,
|
||||||
CaseSensitive.no) == 3, typeStr);
|
No.caseSensitive) == 3, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("EF"), 6,
|
assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("EF"), 6,
|
||||||
CaseSensitive.no) == 5, typeStr);
|
No.caseSensitive) == 5, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("ABCDEFcDEF"), to!T("C"), 8,
|
assert(lastIndexOfAny(to!S("ABCDEFcDEF"), to!T("C"), 8,
|
||||||
CaseSensitive.no) == 6, typeStr);
|
No.caseSensitive) == 6, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("x"), 7,
|
assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("x"), 7,
|
||||||
CaseSensitive.no) == -1, typeStr);
|
No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("abCdefcdef"), to!T("XY"), 4,
|
assert(lastIndexOfAny(to!S("abCdefcdef"), to!T("XY"), 4,
|
||||||
CaseSensitive.no) == -1, typeStr);
|
No.caseSensitive) == -1, typeStr);
|
||||||
assert(lastIndexOfAny(to!S("ÖABCDEFCDEF"), to!T("ö"), 2,
|
assert(lastIndexOfAny(to!S("ÖABCDEFCDEF"), to!T("ö"), 2,
|
||||||
CaseSensitive.no) == 0, typeStr);
|
No.caseSensitive) == 0, typeStr);
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1914,7 +1914,7 @@ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack,
|
||||||
cs = Indicates whether the comparisons are case sensitive.
|
cs = Indicates whether the comparisons are case sensitive.
|
||||||
*/
|
*/
|
||||||
ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes)
|
const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe pure
|
@safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
|
@ -1924,7 +1924,7 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in size_t startIdx,
|
const(Char2)[] needles, in size_t startIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe pure
|
@safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
|
@ -1990,28 +1990,28 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
assert(indexOfNeither("abba", "a") == 1);
|
assert(indexOfNeither("abba", "a") == 1);
|
||||||
|
|
||||||
assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"),
|
assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
assert(indexOfNeither(to!S("def"), to!T("D"),
|
assert(indexOfNeither(to!S("def"), to!T("D"),
|
||||||
CaseSensitive.no) == 1);
|
No.caseSensitive) == 1);
|
||||||
assert(indexOfNeither(to!S("ABca"), to!T("a"),
|
assert(indexOfNeither(to!S("ABca"), to!T("a"),
|
||||||
CaseSensitive.no) == 1);
|
No.caseSensitive) == 1);
|
||||||
assert(indexOfNeither(to!S("def"), to!T("f"),
|
assert(indexOfNeither(to!S("def"), to!T("f"),
|
||||||
CaseSensitive.no) == 0);
|
No.caseSensitive) == 0);
|
||||||
assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"),
|
assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"),
|
||||||
CaseSensitive.no) == 6);
|
No.caseSensitive) == 6);
|
||||||
if (is(S == string))
|
if (is(S == string))
|
||||||
{
|
{
|
||||||
assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
||||||
CaseSensitive.no) == 8,
|
No.caseSensitive) == 8,
|
||||||
to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
||||||
CaseSensitive.no)));
|
No.caseSensitive)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
||||||
CaseSensitive.no) == 7,
|
No.caseSensitive) == 7,
|
||||||
to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"),
|
||||||
CaseSensitive.no)));
|
No.caseSensitive)));
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
@ -2037,26 +2037,26 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
to!string(indexOfNeither(to!S("def"), to!T("a"), 1)));
|
to!string(indexOfNeither(to!S("def"), to!T("a"), 1)));
|
||||||
|
|
||||||
assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"), 4,
|
assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"), 4,
|
||||||
CaseSensitive.no) == 4);
|
No.caseSensitive) == 4);
|
||||||
assert(indexOfNeither(to!S("def"), to!T("D"), 2,
|
assert(indexOfNeither(to!S("def"), to!T("D"), 2,
|
||||||
CaseSensitive.no) == 2);
|
No.caseSensitive) == 2);
|
||||||
assert(indexOfNeither(to!S("ABca"), to!T("a"), 3,
|
assert(indexOfNeither(to!S("ABca"), to!T("a"), 3,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfNeither(to!S("def"), to!T("tzf"), 2,
|
assert(indexOfNeither(to!S("def"), to!T("tzf"), 2,
|
||||||
CaseSensitive.no) == -1);
|
No.caseSensitive) == -1);
|
||||||
assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"), 5,
|
assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"), 5,
|
||||||
CaseSensitive.no) == 6);
|
No.caseSensitive) == 6);
|
||||||
if (is(S == string))
|
if (is(S == string))
|
||||||
{
|
{
|
||||||
assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2,
|
assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2,
|
||||||
CaseSensitive.no) == 3, to!string(indexOfNeither(
|
No.caseSensitive) == 3, to!string(indexOfNeither(
|
||||||
to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no)));
|
to!S("öDfEfffg"), to!T("äDi"), 2, No.caseSensitive)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2,
|
assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2,
|
||||||
CaseSensitive.no) == 2, to!string(indexOfNeither(
|
No.caseSensitive) == 2, to!string(indexOfNeither(
|
||||||
to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no)));
|
to!S("öDfEfffg"), to!T("äDi"), 2, No.caseSensitive)));
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
@ -2078,7 +2078,7 @@ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
cs = Indicates whether the comparisons are case sensitive.
|
cs = Indicates whether the comparisons are case sensitive.
|
||||||
*/
|
*/
|
||||||
ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes)
|
const(Char2)[] needles, in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe pure
|
@safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
|
@ -2088,7 +2088,7 @@ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
/// Ditto
|
/// Ditto
|
||||||
ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
const(Char2)[] needles, in size_t stopIdx,
|
const(Char2)[] needles, in size_t stopIdx,
|
||||||
in CaseSensitive cs = CaseSensitive.yes)
|
in CaseSensitive cs = Yes.caseSensitive)
|
||||||
@safe pure
|
@safe pure
|
||||||
if (isSomeChar!Char && isSomeChar!Char2)
|
if (isSomeChar!Char && isSomeChar!Char2)
|
||||||
{
|
{
|
||||||
|
@ -2158,20 +2158,20 @@ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
||||||
|
|
||||||
assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"),
|
assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"),
|
||||||
CaseSensitive.no) == 5);
|
No.caseSensitive) == 5);
|
||||||
assert(lastIndexOfNeither(to!S("def"), to!T("MI6"),
|
assert(lastIndexOfNeither(to!S("def"), to!T("MI6"),
|
||||||
CaseSensitive.no) == 2, to!string(lastIndexOfNeither(to!S("def"),
|
No.caseSensitive) == 2, to!string(lastIndexOfNeither(to!S("def"),
|
||||||
to!T("MI6"), CaseSensitive.no)));
|
to!T("MI6"), No.caseSensitive)));
|
||||||
assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"),
|
assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"),
|
||||||
CaseSensitive.no) == 6, to!string(lastIndexOfNeither(
|
No.caseSensitive) == 6, to!string(lastIndexOfNeither(
|
||||||
to!S("abbadeafsb"), to!T("fSb"), CaseSensitive.no)));
|
to!S("abbadeafsb"), to!T("fSb"), No.caseSensitive)));
|
||||||
assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"),
|
assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"),
|
||||||
CaseSensitive.no) == 1);
|
No.caseSensitive) == 1);
|
||||||
assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"),
|
assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"),
|
||||||
CaseSensitive.no) == 6);
|
No.caseSensitive) == 6);
|
||||||
assert(lastIndexOfNeither(to!S("dfeffgfffö"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"),
|
assert(lastIndexOfNeither(to!S("dfeffgfffö"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"),
|
||||||
CaseSensitive.no) == 8, to!string(lastIndexOfNeither(to!S("dfeffgfffö"),
|
No.caseSensitive) == 8, to!string(lastIndexOfNeither(to!S("dfeffgfffö"),
|
||||||
to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"), CaseSensitive.no)));
|
to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"), No.caseSensitive)));
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2206,18 +2206,18 @@ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack,
|
||||||
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
assert(foundOeIdx == oeIdx, to!string(foundOeIdx));
|
||||||
|
|
||||||
assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"), 6,
|
assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"), 6,
|
||||||
CaseSensitive.no) == 5);
|
No.caseSensitive) == 5);
|
||||||
assert(lastIndexOfNeither(to!S("def"), to!T("MI6"), 2,
|
assert(lastIndexOfNeither(to!S("def"), to!T("MI6"), 2,
|
||||||
CaseSensitive.no) == 1, to!string(lastIndexOfNeither(to!S("def"),
|
No.caseSensitive) == 1, to!string(lastIndexOfNeither(to!S("def"),
|
||||||
to!T("MI6"), 2, CaseSensitive.no)));
|
to!T("MI6"), 2, No.caseSensitive)));
|
||||||
assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"), 6,
|
assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"), 6,
|
||||||
CaseSensitive.no) == 5, to!string(lastIndexOfNeither(
|
No.caseSensitive) == 5, to!string(lastIndexOfNeither(
|
||||||
to!S("abbadeafsb"), to!T("fSb"), 6, CaseSensitive.no)));
|
to!S("abbadeafsb"), to!T("fSb"), 6, No.caseSensitive)));
|
||||||
assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"), 3,
|
assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"), 3,
|
||||||
CaseSensitive.no) == 1);
|
No.caseSensitive) == 1);
|
||||||
assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"), 2,
|
assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"), 2,
|
||||||
CaseSensitive.no) == 1, to!string(lastIndexOfNeither(
|
No.caseSensitive) == 1, to!string(lastIndexOfNeither(
|
||||||
to!S("dfefffg"), to!T("NSA"), 2, CaseSensitive.no)));
|
to!S("dfefffg"), to!T("NSA"), 2, No.caseSensitive)));
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2391,7 +2391,7 @@ auto capitalize(S)(auto ref S s)
|
||||||
alias KeepTerminator = Flag!"keepTerminator";
|
alias KeepTerminator = Flag!"keepTerminator";
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pure
|
S[] splitLines(S)(S s, in KeepTerminator keepTerm = No.keepTerminator) @safe pure
|
||||||
if (isSomeString!S)
|
if (isSomeString!S)
|
||||||
{
|
{
|
||||||
import std.array : appender;
|
import std.array : appender;
|
||||||
|
@ -2405,14 +2405,14 @@ S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pur
|
||||||
switch (s[i])
|
switch (s[i])
|
||||||
{
|
{
|
||||||
case '\v', '\f', '\n':
|
case '\v', '\f', '\n':
|
||||||
retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes)]);
|
retval.put(s[iStart .. i + (keepTerm == Yes.keepTerminator)]);
|
||||||
iStart = i + 1;
|
iStart = i + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
if (i + 1 < s.length && s[i + 1] == '\n')
|
if (i + 1 < s.length && s[i + 1] == '\n')
|
||||||
{
|
{
|
||||||
retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 2]);
|
retval.put(s[iStart .. i + (keepTerm == Yes.keepTerminator) * 2]);
|
||||||
iStart = i + 2;
|
iStart = i + 2;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -2434,7 +2434,7 @@ S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pur
|
||||||
(s[i + 2] == 0xA8 || s[i + 2] == 0xA9)
|
(s[i + 2] == 0xA8 || s[i + 2] == 0xA9)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 3]);
|
retval.put(s[iStart .. i + (keepTerm == Yes.keepTerminator) * 3]);
|
||||||
iStart = i + 3;
|
iStart = i + 3;
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
@ -2447,7 +2447,7 @@ S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pur
|
||||||
case 0xC2:
|
case 0xC2:
|
||||||
if (i + 1 < s.length && s[i + 1] == 0x85)
|
if (i + 1 < s.length && s[i + 1] == 0x85)
|
||||||
{
|
{
|
||||||
retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 2]);
|
retval.put(s[iStart .. i + (keepTerm == Yes.keepTerminator) * 2]);
|
||||||
iStart = i + 2;
|
iStart = i + 2;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -2487,7 +2487,7 @@ S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pur
|
||||||
assert(splitLines(s) == [s]);
|
assert(splitLines(s) == [s]);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = KeepTerminator.no)
|
auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = No.keepTerminator)
|
||||||
if (!isSomeString!S && is(StringTypeOf!S))
|
if (!isSomeString!S && is(StringTypeOf!S))
|
||||||
{
|
{
|
||||||
return splitLines!(StringTypeOf!S)(s, keepTerm);
|
return splitLines!(StringTypeOf!S)(s, keepTerm);
|
||||||
|
@ -2535,7 +2535,7 @@ auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = KeepTerminator.no)
|
||||||
auto ulines = splitLines(cast(char[])u);
|
auto ulines = splitLines(cast(char[])u);
|
||||||
assert(cast(ubyte[])(ulines[0]) == u);
|
assert(cast(ubyte[])(ulines[0]) == u);
|
||||||
|
|
||||||
lines = splitLines(s, KeepTerminator.yes);
|
lines = splitLines(s, Yes.keepTerminator);
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[0] == "\r");
|
assert(lines[0] == "\r");
|
||||||
assert(lines[1] == "peter\n");
|
assert(lines[1] == "peter\n");
|
||||||
|
@ -2557,14 +2557,14 @@ auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = KeepTerminator.no)
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[9] == "mon\u2030day");
|
assert(lines[9] == "mon\u2030day");
|
||||||
|
|
||||||
lines = splitLines(s, KeepTerminator.yes);
|
lines = splitLines(s, Yes.keepTerminator);
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[13] == "cookies");
|
assert(lines[13] == "cookies");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct LineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)
|
private struct LineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)
|
||||||
{
|
{
|
||||||
import std.conv : unsigned;
|
import std.conv : unsigned;
|
||||||
import std.uni : lineSep, paraSep;
|
import std.uni : lineSep, paraSep;
|
||||||
|
@ -2612,14 +2612,14 @@ public:
|
||||||
switch (_input[i])
|
switch (_input[i])
|
||||||
{
|
{
|
||||||
case '\v', '\f', '\n':
|
case '\v', '\f', '\n':
|
||||||
iEnd = i + (keepTerm == KeepTerminator.yes);
|
iEnd = i + (keepTerm == Yes.keepTerminator);
|
||||||
iNext = i + 1;
|
iNext = i + 1;
|
||||||
break Loop;
|
break Loop;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
if (i + 1 < _input.length && _input[i + 1] == '\n')
|
if (i + 1 < _input.length && _input[i + 1] == '\n')
|
||||||
{
|
{
|
||||||
iEnd = i + (keepTerm == KeepTerminator.yes) * 2;
|
iEnd = i + (keepTerm == Yes.keepTerminator) * 2;
|
||||||
iNext = i + 2;
|
iNext = i + 2;
|
||||||
break Loop;
|
break Loop;
|
||||||
}
|
}
|
||||||
|
@ -2640,7 +2640,7 @@ public:
|
||||||
(_input[i + 2] == 0xA8 || _input[i + 2] == 0xA9)
|
(_input[i + 2] == 0xA8 || _input[i + 2] == 0xA9)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
iEnd = i + (keepTerm == KeepTerminator.yes) * 3;
|
iEnd = i + (keepTerm == Yes.keepTerminator) * 3;
|
||||||
iNext = i + 3;
|
iNext = i + 3;
|
||||||
break Loop;
|
break Loop;
|
||||||
}
|
}
|
||||||
|
@ -2652,7 +2652,7 @@ public:
|
||||||
case 0xC2:
|
case 0xC2:
|
||||||
if (i + 1 < _input.length && _input[i + 1] == 0x85)
|
if (i + 1 < _input.length && _input[i + 1] == 0x85)
|
||||||
{
|
{
|
||||||
iEnd = i + (keepTerm == KeepTerminator.yes) * 2;
|
iEnd = i + (keepTerm == Yes.keepTerminator) * 2;
|
||||||
iNext = i + 2;
|
iNext = i + 2;
|
||||||
break Loop;
|
break Loop;
|
||||||
}
|
}
|
||||||
|
@ -2700,7 +2700,7 @@ public:
|
||||||
* Split an array or slicable range of characters into a range of lines
|
* Split an array or slicable range of characters into a range of lines
|
||||||
using $(D '\r'), $(D '\n'), $(D '\v'), $(D '\f'), $(D "\r\n"),
|
using $(D '\r'), $(D '\n'), $(D '\v'), $(D '\f'), $(D "\r\n"),
|
||||||
$(REF lineSep, std,uni), $(REF paraSep, std,uni) and $(D '\u0085') (NEL)
|
$(REF lineSep, std,uni), $(REF paraSep, std,uni) and $(D '\u0085') (NEL)
|
||||||
as delimiters. If $(D keepTerm) is set to $(D KeepTerminator.yes), then the
|
as delimiters. If $(D keepTerm) is set to $(D Yes.keepTerminator), then the
|
||||||
delimiter is included in the slices returned.
|
delimiter is included in the slices returned.
|
||||||
|
|
||||||
Does not throw on invalid UTF; such is simply passed unchanged
|
Does not throw on invalid UTF; such is simply passed unchanged
|
||||||
|
@ -2721,7 +2721,7 @@ public:
|
||||||
$(REF splitter, std,algorithm)
|
$(REF splitter, std,algorithm)
|
||||||
$(REF splitter, std,regex)
|
$(REF splitter, std,regex)
|
||||||
*/
|
*/
|
||||||
auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(Range r)
|
auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(Range r)
|
||||||
if ((hasSlicing!Range && hasLength!Range && isSomeChar!(ElementType!Range) ||
|
if ((hasSlicing!Range && hasLength!Range && isSomeChar!(ElementType!Range) ||
|
||||||
isSomeString!Range) &&
|
isSomeString!Range) &&
|
||||||
!isConvertibleToString!Range)
|
!isConvertibleToString!Range)
|
||||||
|
@ -2742,7 +2742,7 @@ auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(Range r)
|
||||||
assert(lineSplitter(s).array == splitLines(s));
|
assert(lineSplitter(s).array == splitLines(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(auto ref Range r)
|
auto lineSplitter(KeepTerminator keepTerm = No.keepTerminator, Range)(auto ref Range r)
|
||||||
if (isConvertibleToString!Range)
|
if (isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
return LineSplitter!(keepTerm, StringTypeOf!Range)(r);
|
return LineSplitter!(keepTerm, StringTypeOf!Range)(r);
|
||||||
|
@ -2787,7 +2787,7 @@ auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(auto ref R
|
||||||
auto ulines = lineSplitter(cast(char[])u).array;
|
auto ulines = lineSplitter(cast(char[])u).array;
|
||||||
assert(cast(ubyte[])(ulines[0]) == u);
|
assert(cast(ubyte[])(ulines[0]) == u);
|
||||||
|
|
||||||
lines = lineSplitter!(KeepTerminator.yes)(s).array;
|
lines = lineSplitter!(Yes.keepTerminator)(s).array;
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[0] == "\r");
|
assert(lines[0] == "\r");
|
||||||
assert(lines[1] == "peter\n");
|
assert(lines[1] == "peter\n");
|
||||||
|
@ -2809,7 +2809,7 @@ auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(auto ref R
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[9] == "mon\u2030day");
|
assert(lines[9] == "mon\u2030day");
|
||||||
|
|
||||||
lines = lineSplitter!(KeepTerminator.yes)(s).array;
|
lines = lineSplitter!(Yes.keepTerminator)(s).array;
|
||||||
assert(lines.length == 14);
|
assert(lines.length == 14);
|
||||||
assert(lines[13] == "cookies");
|
assert(lines[13] == "cookies");
|
||||||
}
|
}
|
||||||
|
@ -2841,7 +2841,7 @@ auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(auto ref R
|
||||||
@safe pure unittest
|
@safe pure unittest
|
||||||
{
|
{
|
||||||
auto s = "line1\nline2";
|
auto s = "line1\nline2";
|
||||||
auto spl0 = s.lineSplitter!(KeepTerminator.yes);
|
auto spl0 = s.lineSplitter!(Yes.keepTerminator);
|
||||||
auto spl1 = spl0.save;
|
auto spl1 = spl0.save;
|
||||||
spl0.popFront;
|
spl0.popFront;
|
||||||
assert(spl1.front ~ spl0.front == s);
|
assert(spl1.front ~ spl0.front == s);
|
||||||
|
@ -6700,7 +6700,7 @@ S wrap(S)(S s, in size_t columns = 80, S firstindent = null,
|
||||||
*/
|
*/
|
||||||
S outdent(S)(S str) @safe pure if (isSomeString!S)
|
S outdent(S)(S str) @safe pure if (isSomeString!S)
|
||||||
{
|
{
|
||||||
return str.splitLines(KeepTerminator.yes).outdent().join();
|
return str.splitLines(Yes.keepTerminator).outdent().join();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
56
std/utf.d
56
std/utf.d
|
@ -20,7 +20,7 @@ module std.utf;
|
||||||
import std.meta; // AliasSeq
|
import std.meta; // AliasSeq
|
||||||
import std.range.primitives;
|
import std.range.primitives;
|
||||||
import std.traits; // isSomeChar, isSomeString
|
import std.traits; // isSomeChar, isSomeString
|
||||||
import std.typecons; // Flag
|
import std.typecons; // Flag, Yes, No
|
||||||
import std.exception; // basicExceptionCtors
|
import std.exception; // basicExceptionCtors
|
||||||
|
|
||||||
//debug=utf; // uncomment to turn on debugging printf's
|
//debug=utf; // uncomment to turn on debugging printf's
|
||||||
|
@ -999,9 +999,9 @@ alias UseReplacementDchar = Flag!"useReplacementDchar";
|
||||||
|
|
||||||
Throws:
|
Throws:
|
||||||
$(LREF UTFException) if $(D str[index]) is not the start of a valid UTF
|
$(LREF UTFException) if $(D str[index]) is not the start of a valid UTF
|
||||||
sequence and useReplacementDchar is UseReplacementDchar.no
|
sequence and useReplacementDchar is $(D No.useReplacementDchar)
|
||||||
+/
|
+/
|
||||||
dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index)
|
dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(auto ref S str, ref size_t index)
|
||||||
if (!isSomeString!S &&
|
if (!isSomeString!S &&
|
||||||
isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S))
|
isRandomAccessRange!S && hasSlicing!S && hasLength!S && isSomeChar!(ElementType!S))
|
||||||
in
|
in
|
||||||
|
@ -1020,7 +1020,7 @@ body
|
||||||
return decodeImpl!(true, useReplacementDchar)(str, index);
|
return decodeImpl!(true, useReplacementDchar)(str, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
|
dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
|
||||||
auto ref S str, ref size_t index) @trusted pure if (isSomeString!S)
|
auto ref S str, ref size_t index) @trusted pure if (isSomeString!S)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -1061,7 +1061,7 @@ body
|
||||||
type of range being used and how many code units had to be popped off
|
type of range being used and how many code units had to be popped off
|
||||||
before the code point was determined to be invalid.
|
before the code point was determined to be invalid.
|
||||||
+/
|
+/
|
||||||
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
|
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
|
||||||
ref S str, out size_t numCodeUnits) if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S))
|
ref S str, out size_t numCodeUnits) if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S))
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -1097,7 +1097,7 @@ body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
|
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
|
||||||
ref S str, out size_t numCodeUnits) @trusted pure if (isSomeString!S)
|
ref S str, out size_t numCodeUnits) @trusted pure if (isSomeString!S)
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -1125,7 +1125,7 @@ body
|
||||||
}
|
}
|
||||||
|
|
||||||
/++ Ditto +/
|
/++ Ditto +/
|
||||||
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(ref S str)
|
dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(ref S str)
|
||||||
if (isInputRange!S && isSomeChar!(ElementType!S))
|
if (isInputRange!S && isSomeChar!(ElementType!S))
|
||||||
{
|
{
|
||||||
size_t numCodeUnits;
|
size_t numCodeUnits;
|
||||||
|
@ -1161,7 +1161,7 @@ package template codeUnitLimit(S)
|
||||||
* Returns:
|
* Returns:
|
||||||
* decoded character
|
* decoded character
|
||||||
*/
|
*/
|
||||||
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
|
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
|
||||||
auto ref S str, ref size_t index) if (
|
auto ref S str, ref size_t index) if (
|
||||||
is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char)))
|
is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char)))
|
||||||
{
|
{
|
||||||
|
@ -1385,13 +1385,13 @@ unittest
|
||||||
{
|
{
|
||||||
auto r = R(s);
|
auto r = R(s);
|
||||||
size_t index;
|
size_t index;
|
||||||
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
|
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
|
||||||
assert(dc == replacementDchar);
|
assert(dc == replacementDchar);
|
||||||
assert(1 <= index && index <= s.length);
|
assert(1 <= index && index <= s.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)
|
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)
|
||||||
(auto ref S str, ref size_t index)
|
(auto ref S str, ref size_t index)
|
||||||
if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar)))
|
if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar)))
|
||||||
{
|
{
|
||||||
|
@ -1502,13 +1502,13 @@ unittest
|
||||||
{
|
{
|
||||||
auto r = R(s);
|
auto r = R(s);
|
||||||
size_t index;
|
size_t index;
|
||||||
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
|
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
|
||||||
assert(dc == replacementDchar);
|
assert(dc == replacementDchar);
|
||||||
assert(1 <= index && index <= s.length);
|
assert(1 <= index && index <= s.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
|
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
|
||||||
auto ref S str, ref size_t index)
|
auto ref S str, ref size_t index)
|
||||||
if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar)))
|
if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar)))
|
||||||
{
|
{
|
||||||
|
@ -1566,7 +1566,7 @@ unittest
|
||||||
{
|
{
|
||||||
auto r = R(s);
|
auto r = R(s);
|
||||||
size_t index;
|
size_t index;
|
||||||
dchar dc = decodeImpl!(false, Flag!"useReplacementDchar".yes)(r, index);
|
dchar dc = decodeImpl!(false, Yes.useReplacementDchar)(r, index);
|
||||||
assert(dc == replacementDchar);
|
assert(dc == replacementDchar);
|
||||||
assert(1 <= index && index <= s.length);
|
assert(1 <= index && index <= s.length);
|
||||||
}
|
}
|
||||||
|
@ -1860,7 +1860,7 @@ private dchar _utfException(UseReplacementDchar useReplacementDchar)(string msg,
|
||||||
Throws:
|
Throws:
|
||||||
$(D UTFException) if $(D c) is not a valid UTF code point.
|
$(D UTFException) if $(D c) is not a valid UTF code point.
|
||||||
+/
|
+/
|
||||||
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref char[4] buf, dchar c) @safe pure
|
ref char[4] buf, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
if (c <= 0x7F)
|
if (c <= 0x7F)
|
||||||
|
@ -1928,14 +1928,14 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
|
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
|
||||||
assert(buf.front == replacementDchar);
|
assert(buf.front == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref wchar[2] buf, dchar c) @safe pure
|
ref wchar[2] buf, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
if (c <= 0xFFFF)
|
if (c <= 0xFFFF)
|
||||||
|
@ -1981,14 +1981,14 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
|
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
|
||||||
assert(buf.front == replacementDchar);
|
assert(buf.front == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Ditto
|
/// Ditto
|
||||||
size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref dchar[1] buf, dchar c) @safe pure
|
ref dchar[1] buf, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
|
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
|
||||||
|
@ -2019,7 +2019,7 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
assertThrown!UTFException(encode(buf, cast(dchar)0xDFFF));
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000) == buf.stride);
|
assert(encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000) == buf.stride);
|
||||||
assert(buf.front == replacementDchar);
|
assert(buf.front == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2031,7 +2031,7 @@ size_t encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
Throws:
|
Throws:
|
||||||
$(D UTFException) if $(D c) is not a valid UTF code point.
|
$(D UTFException) if $(D c) is not a valid UTF code point.
|
||||||
+/
|
+/
|
||||||
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref char[] str, dchar c) @safe pure
|
ref char[] str, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
char[] r = str;
|
char[] r = str;
|
||||||
|
@ -2134,13 +2134,13 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(buf.back != replacementDchar);
|
assert(buf.back != replacementDchar);
|
||||||
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
|
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
|
||||||
assert(buf.back == replacementDchar);
|
assert(buf.back == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref wchar[] str, dchar c) @safe pure
|
ref wchar[] str, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
wchar[] r = str;
|
wchar[] r = str;
|
||||||
|
@ -2195,13 +2195,13 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(buf.back != replacementDchar);
|
assert(buf.back != replacementDchar);
|
||||||
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
|
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
|
||||||
assert(buf.back == replacementDchar);
|
assert(buf.back == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ditto
|
/// ditto
|
||||||
void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
|
||||||
ref dchar[] str, dchar c) @safe pure
|
ref dchar[] str, dchar c) @safe pure
|
||||||
{
|
{
|
||||||
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
|
if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
|
||||||
|
@ -2232,7 +2232,7 @@ void encode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no)(
|
||||||
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
assertThrown!UTFException(encode(buf, cast(dchar)0x110000));
|
||||||
|
|
||||||
assert(buf.back != replacementDchar);
|
assert(buf.back != replacementDchar);
|
||||||
encode!(UseReplacementDchar.yes)(buf, cast(dchar)0x110000);
|
encode!(Yes.useReplacementDchar)(buf, cast(dchar)0x110000);
|
||||||
assert(buf.back == replacementDchar);
|
assert(buf.back == replacementDchar);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3597,13 +3597,13 @@ template byUTF(C) if (isSomeChar!C)
|
||||||
{
|
{
|
||||||
static if (is(RC == dchar))
|
static if (is(RC == dchar))
|
||||||
{
|
{
|
||||||
fill = cast(ushort) encode!(UseReplacementDchar.yes)(buf, c);
|
fill = cast(ushort) encode!(Yes.useReplacementDchar)(buf, c);
|
||||||
r.popFront;
|
r.popFront;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fill = cast(ushort) encode!(UseReplacementDchar.yes)(
|
fill = cast(ushort) encode!(Yes.useReplacementDchar)(
|
||||||
buf, decodeFront!(UseReplacementDchar.yes)(r));
|
buf, decodeFront!(Yes.useReplacementDchar)(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue