summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-05-16 07:52:46 +0200
committerEugen Wissner <belka@caraus.de>2021-05-16 07:52:46 +0200
commitb62cbb0647550ce54dc04ce6dc3a136fdb172bd7 (patch)
tree8f7731d6a05d2f96ac143d6d19ed557a0661f728 /tests
parent2c21dc34296ad9eeadae45b96a1e07853dbae84f (diff)
downloadtanya-b62cbb0647550ce54dc04ce6dc3a136fdb172bd7.tar.gz
Use std searching and iteration
Diffstat (limited to 'tests')
-rw-r--r--tests/tanya/algorithm/tests/iteration.d74
-rw-r--r--tests/tanya/algorithm/tests/searching.d17
2 files changed, 1 insertions, 90 deletions
diff --git a/tests/tanya/algorithm/tests/iteration.d b/tests/tanya/algorithm/tests/iteration.d
index 52e99b3..9594d5e 100644
--- a/tests/tanya/algorithm/tests/iteration.d
+++ b/tests/tanya/algorithm/tests/iteration.d
@@ -1,85 +1,13 @@
/* 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.iteration;
import tanya.algorithm.iteration;
import tanya.range;
import tanya.test.stub;
-// length is unknown when taking from a range without length
-@nogc nothrow pure @safe unittest
-{
- static struct R
- {
- mixin InputRangeStub;
- }
- auto actual = take(R(), 100);
-
- static assert(!hasLength!(typeof(actual)));
-}
-
-// Takes minimum length if the range length > n
-@nogc nothrow pure @safe unittest
-{
- auto range = take(cast(int[]) null, 8);
- assert(range.length == 0);
-}
-
-@nogc nothrow pure @safe unittest
-{
- const int[9] range = [1, 2, 3, 4, 5, 6, 7, 8, 9];
- {
- auto slice = take(range[], 8)[1 .. 3];
-
- assert(slice.length == 2);
- assert(slice.front == 2);
- assert(slice.back == 3);
- }
- {
- auto slice = takeExactly(range[], 8)[1 .. 3];
-
- assert(slice.length == 2);
- assert(slice.front == 2);
- assert(slice.back == 3);
- }
-}
-
-// Elements are accessible in reverse order
-@nogc nothrow pure @safe unittest
-{
- const int[3] given = [1, 2, 3];
- auto actual = retro(given[]);
-
- assert(actual.back == given[].front);
- assert(actual[0] == 3);
- assert(actual[2] == 1);
-
- actual.popBack();
- assert(actual.back == 2);
- assert(actual[1] == 2);
-
- // Check slicing.
- auto slice = retro(given[])[1 .. $];
- assert(slice.length == 2 && slice.front == 2 && slice.back == 1);
-}
-
-// Elements can be assigned
-@nogc nothrow pure @safe unittest
-{
- int[4] given = [1, 2, 3, 4];
- auto actual = retro(given[]);
-
- actual.front = 5;
- assert(given[].back == 5);
-
- actual.back = 8;
- assert(given[].front == 8);
-
- actual[2] = 10;
- assert(given[1] == 10);
-}
-
// Singleton range is bidirectional and random-access
@nogc nothrow pure @safe unittest
{
diff --git a/tests/tanya/algorithm/tests/searching.d b/tests/tanya/algorithm/tests/searching.d
deleted file mode 100644
index ca8fdb0..0000000
--- a/tests/tanya/algorithm/tests/searching.d
+++ /dev/null
@@ -1,17 +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.searching;
-
-import tanya.algorithm.searching;
-import tanya.test.stub;
-
-@nogc nothrow pure @safe unittest
-{
- @Count(3)
- static struct Range
- {
- mixin InputRangeStub!int;
- }
- assert(count(Range()) == 3);
-}