Sha256: c4fb0481d250a4754b686604b637aad4f3585cfe1e2eef3203e152eacdf91d08

Contents?: true

Size: 1.47 KB

Versions: 112

Compression:

Stored size: 1.47 KB

Contents

<?php

require "run-length-encoding.php";

/**
 * Class RunLengthEncodingTest
 */
class RunLengthEncodingTest extends PHPUnit\Framework\TestCase
{
    public function testEncodeEmptyString()
    {
        $this->assertEquals('', encode(''));
    }

    public function testEncodeSingleCharactersOnly()
    {
        $this->assertEquals('XYZ', encode('XYZ'));
    }

    public function testDecodeEmptyString()
    {
        $this->assertEquals('', decode(''));
    }

    public function testDecodeSingleCharactersOnly()
    {
        $this->assertEquals('XYZ', decode('XYZ'));
    }

    public function testEncodeSimple()
    {
        $this->assertEquals('2A3B4C', encode('AABBBCCCC'));
    }

    public function testDecodeSimple()
    {
        $this->assertEquals('AABBBCCCC', decode('2A3B4C'));
    }

    public function testEncodeWithSingleValues()
    {
        $this->assertEquals(
            '12WB12W3B24WB',
            encode('WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB')
        );
    }

    public function testDecodeWithSingleValues()
    {
        $this->assertEquals(
            'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB',
            decode('12WB12W3B24WB')
        );
    }

    public function testDecodeMultipleWhitespaceMixedInString()
    {
        $this->assertEquals('  hsqq qww  ', decode('2 hs2q q2w2 '));
    }

    public function testEncodeDecodeCombination()
    {
        $this->assertEquals('zzz ZZ  zZ', decode(encode('zzz ZZ  zZ')));
    }
}

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.158 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.157 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.156 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.155 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.154 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.153 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.152 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.151 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.150 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.149 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.148 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.147 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.146 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.145 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.144 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.143 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.142 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.141 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php
trackler-2.2.1.140 tracks/php/exercises/run-length-encoding/run-length-encoding_test.php