RangeIteratorTest::testRangeIteratorWithStepZero()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace itertools;
4
5
use PHPUnit_Framework_TestCase;
6
7
8
class RangeIteratorTest extends PHPUnit_Framework_TestCase
9
{
10
	/** @test */
11
	public function testRangeIteratorWithFiniteRange()
12
	{
13
		$this->assertEquals(range(1, 10), $this->irange(1, 10));
14
		$this->assertEquals(range(2, -10, -1), $this->irange(2, -10, -1));
15
	}
16
17
	/** @test */
18
	public function testRangeIteratorWithStepZero()
19
	{
20
		$range = new SliceIterator(new RangeIterator(1, 2, 0), 0, 20);
21
		$this->assertEquals(array_fill(0, 20, 1), iterator_to_array($range));
22
	}
23
24
	/** @test */
25
	public function testRangeIteratorWithInfiniteRange()
26
	{
27
		$infinteRange = new SliceIterator(new RangeIterator(1), 0, 10);
28
		$this->assertEquals(range(1, 10), iterator_to_array($infinteRange));
29
	}
30
31
	protected function irange($start, $end = null, $step = 1)
32
	{
33
		return iterator_to_array(new RangeIterator($start, $end, $step));
34
	}
35
}
36
37