Sha256: d42fa0cf7b2ddd5ab983790a46dea9fa276fbc2cf22f8ff36f7372899d30910d

Contents?: true

Size: 1.83 KB

Versions: 300

Compression:

Stored size: 1.83 KB

Contents

<?php

require_once 'binary.php';

class BinaryTest extends PHPUnit\Framework\TestCase
{
    public function testItParsesBinary0ToDecimal0()
    {
        $this->assertEquals(0, parse_binary('0'));
    }

    public function testItParsesBinary1ToDecimal1()
    {
        $this->assertEquals(1, parse_binary('1'));
    }

    public function testItParsesDigits()
    {
        $this->markTestSkipped();

        $this->assertEquals(2, parse_binary('10'));
        $this->assertEquals(3, parse_binary('11'));
        $this->assertEquals(4, parse_binary('100'));
        $this->assertEquals(9, parse_binary('1001'));
    }

    public function testItParsesHundreds()
    {
        $this->markTestSkipped();

        $this->assertEquals(128, parse_binary('10000000'));
        $this->assertEquals(315, parse_binary('100111011'));
        $this->assertEquals(800, parse_binary('1100100000'));
        $this->assertEquals(999, parse_binary('1111100111'));
    }

    public function testItParsesMaxInt()
    {
        $this->markTestSkipped();

        $this->assertEquals(
            9223372036854775807,
            parse_binary('111111111111111111111111111111111111111111111111111111111111111')
        );
    }

    public function testItParsesValuesWithLeadingZeros()
    {
        $this->markTestSkipped();

        $this->assertEquals(1, parse_binary('01'));
        $this->assertEquals(2, parse_binary('0010'));
        $this->assertEquals(3, parse_binary('00011'));
    }

    /**
     * @dataProvider invalidValues
     */
    public function testItOnlyAcceptsStringsContainingZerosAndOnes($value)
    {
        $this->markTestSkipped();

        $this->expectException(InvalidArgumentException::class);

        parse_binary($value);
    }

    public function invalidValues()
    {
        return [
            ['2'], ['12345'], ['a'], ['0abcdef'],
        ];
    }
}

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.118 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.117 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.116 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.115 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.114 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.113 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.111 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.110 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.109 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.108 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.107 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.106 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.105 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.104 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.103 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.102 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.101 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.100 tracks/php/exercises/binary/binary_test.php
trackler-2.2.1.99 tracks/php/exercises/binary/binary_test.php