From 87e7366d4d9d3de79772b851f8772a4011d6227d Mon Sep 17 00:00:00 2001 From: javalizard <> Date: Sat, 25 Jun 2011 04:56:12 +0000 Subject: Added two methods for getting array elements out of TPriorityList above and below a specific priority, with inclusion. Added TPriorityMap and test cases. --- tests/unit/Collections/TPriorityListTest.php | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'tests/unit/Collections/TPriorityListTest.php') diff --git a/tests/unit/Collections/TPriorityListTest.php b/tests/unit/Collections/TPriorityListTest.php index f329538c..35c712ae 100644 --- a/tests/unit/Collections/TPriorityListTest.php +++ b/tests/unit/Collections/TPriorityListTest.php @@ -964,6 +964,77 @@ class TPriorityListTest extends PHPUnit_Framework_TestCase $this->assertEquals($this->pitem3, $array[100][0]); } + public function testToArrayBelowPriority() { + $array = $this->plist->toArrayBelowPriority(0); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals(1, count($array)); + + $array = $this->plist->toArrayBelowPriority(10); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals(1, count($array)); + + $array = $this->plist->toArrayBelowPriority(10, true); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals($this->pitem1, $array[1]); + $this->assertEquals($this->pitem2, $array[2]); + $this->assertEquals(3, count($array)); + + $array = $this->plist->toArrayBelowPriority(11); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals($this->pitem1, $array[1]); + $this->assertEquals($this->pitem2, $array[2]); + $this->assertEquals(3, count($array)); + + $array = $this->plist->toArrayBelowPriority(100); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals($this->pitem1, $array[1]); + $this->assertEquals($this->pitem2, $array[2]); + $this->assertEquals(3, count($array)); + + $array = $this->plist->toArrayBelowPriority(100, true); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals($this->pitem1, $array[1]); + $this->assertEquals($this->pitem2, $array[2]); + $this->assertEquals($this->pitem3, $array[3]); + $this->assertEquals(4, count($array)); + } + + public function testToArrayAbovePriority() { + $array = $this->plist->toArrayAbovePriority(100, false); + $this->assertEquals(0, count($array)); + + $array = $this->plist->toArrayAbovePriority(100, true); + $this->assertEquals(1, count($array)); + $this->assertEquals($this->pitem3, $array[0]); + + $array = $this->plist->toArrayAbovePriority(10, false); + $this->assertEquals($this->pitem3, $array[0]); + $this->assertEquals(1, count($array)); + + $array = $this->plist->toArrayAbovePriority(10); + $this->assertEquals($this->pitem1, $array[0]); + $this->assertEquals($this->pitem2, $array[1]); + $this->assertEquals($this->pitem3, $array[2]); + $this->assertEquals(3, count($array)); + + $array = $this->plist->toArrayAbovePriority(11); + $this->assertEquals($this->pitem3, $array[0]); + $this->assertEquals(1, count($array)); + + $array = $this->plist->toArrayAbovePriority(0); + $this->assertEquals($this->pitem1, $array[0]); + $this->assertEquals($this->pitem2, $array[1]); + $this->assertEquals($this->pitem3, $array[2]); + $this->assertEquals(3, count($array)); + + $array = $this->plist->toArrayAbovePriority(-10000000, true); + $this->assertEquals($this->pfirst, $array[0]); + $this->assertEquals($this->pitem1, $array[1]); + $this->assertEquals($this->pitem2, $array[2]); + $this->assertEquals($this->pitem3, $array[3]); + $this->assertEquals(4, count($array)); + } + public function testArrayReadTPriorityList() { $this->assertTrue($this->plist[0] === $this->pfirst); -- cgit v1.2.3