mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 19:30:21 +02:00
Implementation of a Zipper, for efficient splice.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
25
tests/HTMLPurifier/ZipperTest.php
Normal file
25
tests/HTMLPurifier/ZipperTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_ZipperTest extends HTMLPurifier_Harness
|
||||
{
|
||||
public function testBasicNavigation() {
|
||||
list($z, $t) = HTMLPurifier_Zipper::fromArray(array(0,1,2,3));
|
||||
$this->assertIdentical($t, 0);
|
||||
$t = $z->next($t);
|
||||
$this->assertIdentical($t, 1);
|
||||
$t = $z->prev($t);
|
||||
$this->assertIdentical($t, 0);
|
||||
$t = $z->advance($t, 2);
|
||||
$this->assertIdentical($t, 2);
|
||||
$t = $z->delete();
|
||||
$this->assertIdentical($t, 3);
|
||||
$z->insertBefore(4);
|
||||
$z->insertAfter(5);
|
||||
$this->assertIdentical($z->toArray($t), array(0,1,4,3,5));
|
||||
$t = $z->splice($t, 2, array(6,7));
|
||||
$this->assertIdentical($t, 6);
|
||||
$this->assertIdentical($z->toArray($t), array(0,1,4,6,7));
|
||||
}
|
||||
|
||||
// ToDo: QuickCheck style test comparing with array_splice
|
||||
}
|
Reference in New Issue
Block a user