|
| 1 | +<?php |
| 2 | + |
| 3 | +require 'counting_sort.php'; |
| 4 | + |
| 5 | +class CountingSortTest extends PHPUnit_Framework_TestCase{ |
| 6 | + |
| 7 | + public function testNoParameters(){ |
| 8 | + $this->assertEmpty(counting_sort([])); |
| 9 | + } |
| 10 | + |
| 11 | + public function testArrayWithUnorderElements(){ |
| 12 | + $original = [3,5,7,1,5,1,2,3,2,71,2,3,4,71,47,7]; |
| 13 | + $copy = [3,5,7,1,5,1,2,3,2,71,2,3,4,71,47,7]; |
| 14 | + sort($copy, SORT_NUMERIC); |
| 15 | + |
| 16 | + $this->assertEquals(counting_sort($original), $copy); |
| 17 | + } |
| 18 | + |
| 19 | + public function testArrayWithOrderelements(){ |
| 20 | + $original = [0,1,2,3,4,5,6,7,8,9,10]; |
| 21 | + $copy = [0,1,2,3,4,5,6,7,8,9,10]; |
| 22 | + |
| 23 | + $this->assertEquals(counting_sort($original), $copy); |
| 24 | + } |
| 25 | + |
| 26 | + public function testArrayWithRepeatedElements(){ |
| 27 | + $original = [1,1,1,1,1,1,1,1,1,1,1]; |
| 28 | + $copy = [1,1,1,1,1,1,1,1,1,1,1]; |
| 29 | + $this->assertEquals(counting_sort($original), $copy); |
| 30 | + } |
| 31 | +} |
0 commit comments