diff options
| author | Eugen Wissner <belka@caraus.de> | 2021-03-11 10:18:02 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2021-03-11 10:18:02 +0100 |
| commit | f27f62b80abf8b237d5c4bf57427fd50aa17e2b0 (patch) | |
| tree | 6d39d74e7abd121d3b24144bbf83bf41205e68c3 /tests | |
| parent | a227b58407b204f9025f11220f2a32911ad8ffb9 (diff) | |
| download | tanya-f27f62b80abf8b237d5c4bf57427fd50aa17e2b0.tar.gz | |
Fix InputRanges for non-copyable elements
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tanya/algorithm/tests/comparison.d | 97 | ||||
| -rw-r--r-- | tests/tanya/algorithm/tests/mutation.d | 8 | ||||
| -rw-r--r-- | tests/tanya/container/tests/array.d | 9 | ||||
| -rw-r--r-- | tests/tanya/net/tests/iface.d | 2 |
4 files changed, 6 insertions, 110 deletions
diff --git a/tests/tanya/algorithm/tests/comparison.d b/tests/tanya/algorithm/tests/comparison.d deleted file mode 100644 index 5bd561a..0000000 --- a/tests/tanya/algorithm/tests/comparison.d +++ /dev/null @@ -1,97 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -module tanya.algorithm.tests.comparison; - -import tanya.algorithm.comparison; -import tanya.math; -import tanya.range; - -@nogc nothrow pure @safe unittest -{ - static assert(!is(typeof(min(1, 1UL)))); -} - -@nogc nothrow pure @safe unittest -{ - assert(min(5, 3) == 3); - assert(min(4, 4) == 4); - assert(min(5.2, 3.0) == 3.0); - - assert(min(5.2, double.nan) == 5.2); - assert(min(double.nan, 3.0) == 3.0); - assert(isNaN(min(double.nan, double.nan))); -} - -@nogc nothrow pure @safe unittest -{ - assert(min(cast(ubyte[]) []).empty); -} - -@nogc nothrow pure @safe unittest -{ - static assert(!is(typeof(max(1, 1UL)))); -} - -@nogc nothrow pure @safe unittest -{ - assert(max(5, 3) == 5); - assert(max(4, 4) == 4); - assert(max(5.2, 3.0) == 5.2); - - assert(max(5.2, double.nan) == 5.2); - assert(max(double.nan, 3.0) == 3.0); - assert(isNaN(max(double.nan, double.nan))); -} - -@nogc nothrow pure @safe unittest -{ - assert(max(cast(ubyte[]) []).empty); -} - -// min/max compare const and mutable structs. -@nogc nothrow pure @safe unittest -{ - static struct S - { - int s; - - int opCmp(typeof(this) that) const @nogc nothrow pure @safe - { - return this.s - that.s; - } - } - { - const s1 = S(1); - assert(min(s1, S(2)).s == 1); - assert(max(s1, S(2)).s == 2); - } - { - auto s2 = S(2), s3 = S(3); - assert(min(s2, s3).s == 2); - assert(max(s2, s3).s == 3); - } -} - -@nogc nothrow pure @safe unittest -{ - static struct OpCmp(int value) - { - int opCmp(OpCmp) @nogc nothrow pure @safe - { - return value; - } - } - { - OpCmp!(-1)[1] range; - assert(compare(range[], range[]) < 0); - } - { - OpCmp!1[1] range; - assert(compare(range[], range[]) > 0); - } - { - OpCmp!0[1] range; - assert(compare(range[], range[]) == 0); - } -} diff --git a/tests/tanya/algorithm/tests/mutation.d b/tests/tanya/algorithm/tests/mutation.d index 5d98233..19ab636 100644 --- a/tests/tanya/algorithm/tests/mutation.d +++ b/tests/tanya/algorithm/tests/mutation.d @@ -17,7 +17,7 @@ import tanya.test.stub; // Copies overlapping arrays @nogc nothrow pure @safe unittest { - import tanya.algorithm.comparison : equal; + import std.algorithm.comparison : equal; int[6] actual = [1, 2, 3, 4, 5, 6]; const int[6] expected = [1, 2, 1, 2, 3, 4]; @@ -94,7 +94,7 @@ import tanya.test.stub; @nogc nothrow pure @safe unittest { - import tanya.algorithm.comparison : equal; + import std.algorithm.comparison : equal; const int[5] expected = [1, 2, 3, 4, 5]; int[5] actual = [4, 5, 1, 2, 3]; @@ -106,7 +106,7 @@ import tanya.test.stub; // Doesn't cause an infinite loop if back is shorter than the front @nogc nothrow pure @safe unittest { - import tanya.algorithm.comparison : equal; + import std.algorithm.comparison : equal; const int[5] expected = [1, 2, 3, 4, 5]; int[5] actual = [3, 4, 5, 1, 2]; @@ -118,7 +118,7 @@ import tanya.test.stub; // Doesn't call .front on an empty front @nogc nothrow pure @safe unittest { - import tanya.algorithm.comparison : equal; + import std.algorithm.comparison : equal; const int[2] expected = [2, 8]; int[2] actual = expected; diff --git a/tests/tanya/container/tests/array.d b/tests/tanya/container/tests/array.d index 6dd90b4..2f2eeec 100644 --- a/tests/tanya/container/tests/array.d +++ b/tests/tanya/container/tests/array.d @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ module tanya.container.tests.array; -import tanya.algorithm.comparison; +import std.algorithm.comparison; import tanya.container.array; import tanya.memory.allocator; import tanya.test.stub; @@ -187,10 +187,3 @@ import tanya.test.stub; } func(array); } - -// Can have non-copyable elements -@nogc nothrow pure @safe unittest -{ - static assert(is(Array!NonCopyable)); - static assert(is(typeof({ Array!NonCopyable.init[0] = NonCopyable(); }))); -} diff --git a/tests/tanya/net/tests/iface.d b/tests/tanya/net/tests/iface.d index 4ddb6f0..c77692a 100644 --- a/tests/tanya/net/tests/iface.d +++ b/tests/tanya/net/tests/iface.d @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ module tanya.net.tests.iface; -import tanya.algorithm.comparison; +import std.algorithm.comparison; import tanya.net.iface; @nogc nothrow @safe unittest |
