Skip to content

Commit 41999dd

Browse files
committed
Add VectorFromIterable test
1 parent f51e588 commit 41999dd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/DsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use function Cdn77\Functions\mapFromIterable;
1212
use function Cdn77\Functions\mappedValueSetsFromIterable;
1313
use function Cdn77\Functions\setFromIterable;
14+
use function Cdn77\Functions\vectorFromIterable;
1415

1516
final class DsTest extends TestCase
1617
{
@@ -64,4 +65,19 @@ public function testSetFromIterable() : void
6465
self::assertCount(2, $set);
6566
self::assertTrue($set->contains(true, false));
6667
}
68+
69+
public function testVectorFromIterable() : void
70+
{
71+
/** @var callable():Generator<int, bool> $iterableFactory */
72+
$iterableFactory = static function () : Generator {
73+
yield 1 => true;
74+
yield 2 => false;
75+
yield 2 => true;
76+
};
77+
78+
$vector = vectorFromIterable($iterableFactory(), static fn (int $_, bool $value) => ! $value);
79+
80+
self::assertCount(3, $vector);
81+
self::assertSame([false, true, false], $vector->toArray());
82+
}
6783
}

0 commit comments

Comments
 (0)