Functional\length test
authorwidmogrod <widmogrod@gmail.com>
Wed, 20 Dec 2017 20:58:36 +0000 (21:58 +0100)
committerwidmogrod <widmogrod@gmail.com>
Wed, 20 Dec 2017 20:58:36 +0000 (21:58 +0100)
test/Functional/LengthTest.php [new file with mode: 0644]

diff --git a/test/Functional/LengthTest.php b/test/Functional/LengthTest.php
new file mode 100644 (file)
index 0000000..b8461ff
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+namespace test\Functional;
+
+use Widmogrod\FantasyLand\Foldable;
+use function Widmogrod\Functional\fromIterable;
+use function Widmogrod\Functional\length;
+
+class LengthTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider provideData
+     */
+    public function test_it_should_return_boxed_value(
+        Foldable $t,
+        int $expected
+    ) {
+        $this->assertEquals(length($t), ($expected));
+    }
+
+    public function provideData()
+    {
+        return [
+            'Empty list should have length 0' => [
+                '$t' => fromIterable([]),
+                '$expected' => 0,
+            ],
+
+            'Finite list should have length' => [
+                '$t' => fromIterable([1, 2, 3, 4]),
+                '$expected' => 4,
+            ],
+        ];
+    }
+}