summaryrefslogtreecommitdiff
path: root/tests/unit/Collections/TPriorityListTest.php
diff options
context:
space:
mode:
authorjavalizard <>2011-06-25 04:56:12 +0000
committerjavalizard <>2011-06-25 04:56:12 +0000
commit87e7366d4d9d3de79772b851f8772a4011d6227d (patch)
tree804e43ee4ec0f7177459f0ffb7ea654f7bfff00b /tests/unit/Collections/TPriorityListTest.php
parent15f6747485b5912f657c2c0fce8f41c01c70d2ad (diff)
Added two methods for getting array elements out of TPriorityList above and below a specific priority, with inclusion. Added TPriorityMap and test cases.
Diffstat (limited to 'tests/unit/Collections/TPriorityListTest.php')
-rw-r--r--tests/unit/Collections/TPriorityListTest.php71
1 files changed, 71 insertions, 0 deletions
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);