PHP Classes

File: compressTest.php

Recommend this page to a friend!
  Classes of Chi H.   PHP RLE Compression Algorithm   compressTest.php   Download  
File: compressTest.php
Role: Unit test script
Content type: text/plain
Description: Unit Test
Class: PHP RLE Compression Algorithm
Compress and decompress data using RLE in pure PHP
Author: By
Last change:
Date: 9 years ago
Size: 1,568 bytes
 

Contents

Class file image Download
<?php
/*
* Copyright (c) 2014 Chi Hoang
* All rights reserved
*/
require_once '/usr/share/php5/PEAR/PHPUnit/Autoload.php';
require_once(
"main.php");

class
compressTest extends PHPUnit_Framework_TestCase
{
  public function
testRLE1Compress()
  {
   
$rle = new Compress\Rle("aaaabbcc","Encode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('a4b2c2'.chr(0xa));
  }
 
  public function
testRLE2Compress()
  {
   
$rle = new Compress\Rle("aabb","Encode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('aabb'.chr(0xa));
  }
 
  public function
testRLE3Compress()
  {
   
$rle = new Compress\Rle("a4b2c2","Decode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('aaaabbcc'.chr(0xa));
  }
 
   public function
testRLE4Compress()
  {
   
$rle = new Compress\Rle("aabb","Decode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('aabb'.chr(0xa));
  }
 
   public function
testRLE5Compress()
  {
   
$rle = new Compress\Rle("aabbe","Encode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('aabbe'.chr(0xa));
  }
 
   public function
testRLE6Compress()
  {
   
$rle = new Compress\Rle("aabbccdeaaaaaaaaaaaaaaaedafcd","Encode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('a2b2c2dea15edafcd'.chr(0xa));
  }
 
   public function
testRLE7Compress()
  {
   
$rle = new Compress\Rle("aabbccdeaaaaaaaaaaaaaaaedafcd","Encode");
   
$rle->start();
    echo
$rle;
   
$this->expectOutputString('a2b2c2dea15edafcd'.chr(0xa));
  }
 


 
 
 
}
?>