PHP 8.2.30
Preview: link_007.phpt Size: 1.32 KB
/opt/cloudlinux/alt-php82/root/usr/share/pear/test/Structures_LinkedList/tests/link_007.phpt

--TEST--
link_007: Test many corner cases
--FILE--
<?php
 
$dir = dirname(__FILE__);
require 'Structures/LinkedList/Double.php';
require 'LinkTester.php';

$xyy = new Structures_LinkedList_Double();

// prepend to an empty list corner case: 1
$xyy->prependNode($tester1);
print "Current: {$xyy->current()->getNumb()}\n";

// prepend to a list with only one element: 21
$xyy->prependNode($tester2);
print "Current: {$xyy->current()->getNumb()}\n";

// insert after tail node corner case: 213
$xyy->insertNode($tester3, $tester1);
print "Current: {$xyy->current()->getNumb()}\n";

// insert before root node corner case: 4213
$xyy->insertNode($tester4, $tester2, true);
print "Current: {$xyy->current()->getNumb()}\n";

// insert before tail node corner case: 42153
$xyy->insertNode($tester5, $tester3, true);
print "Current: {$xyy->current()->getNumb()}\n";

// insert after root node corner case: 421653
$xyy->insertNode($tester6, $tester1);
print "Current: {$xyy->current()->getNumb()}\n";

print "Foreach: ";
foreach ($xyy as $node) {
    print $node->getNumb();
}

print "\nWhile (in reverse): ";
// test reverse iteration with while()
$link = $xyy->end();
do {
    print $link->getNumb();
} while ($link = $xyy->previous());
?>
--EXPECT--
Current: 1
Current: 1
Current: 1
Current: 1
Current: 1
Current: 1
Foreach: 421653
While (in reverse): 356124

Directory Contents

Dirs: 0 × Files: 16

Name Size Perms Modified Actions
492 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
987 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
675 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1000 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
544 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1.21 KB lrw-r--r-- 2023-04-06 15:34:25
Edit Download
991 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1.32 KB lrw-r--r-- 2023-04-06 15:34:25
Edit Download
462 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1000 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
688 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1013 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
557 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1.22 KB lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1004 B lrw-r--r-- 2023-04-06 15:34:25
Edit Download
1.19 KB lrw-r--r-- 2023-04-06 15:34:25
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).