|
| 1 | +<?php |
| 2 | +require 'quicksort.php'; |
| 3 | + |
| 4 | +class QuickSortTest extends PHPUnit_Framework_TestCase{ |
| 5 | + |
| 6 | + public function testWithArrayEmpty(){ |
| 7 | + $this->assertEmpty(quicksort([])); |
| 8 | + } |
| 9 | + |
| 10 | + public function testArrayWithUnorderElements(){ |
| 11 | + $original = [12321,43535,2342423,4364576,2343323,3534534,212,1,2,0,234234,234,34]; |
| 12 | + $copy = [12321,43535,2342423,4364576,2343323,3534534,212,1,2,0,234234,234,34]; |
| 13 | + // Order the array copy |
| 14 | + sort($copy,SORT_NUMERIC); |
| 15 | + |
| 16 | + $this->assertEquals(quicksort($original), $copy); |
| 17 | + } |
| 18 | + |
| 19 | + public function testArrayWithOrderElements(){ |
| 20 | + $original = [1,2,3,4,5,6,7,8,9]; |
| 21 | + $copy = [1,2,3,4,5,6,7,8,9]; |
| 22 | + $this->assertEquals(quicksort($original), $copy); |
| 23 | + } |
| 24 | + |
| 25 | + public function testArrayWithOrderElementsReverOrder(){ |
| 26 | + $original = [9,8,7,6,5,4,3,2,1]; |
| 27 | + $copy = [9,8,7,6,5,4,3,2,1]; |
| 28 | + // Order the array copy |
| 29 | + sort($copy,SORT_NUMERIC); |
| 30 | + |
| 31 | + $this->assertEquals(quicksort($original), $copy); |
| 32 | + } |
| 33 | +} |
0 commit comments