web3.php/test/unit/IntegerFormatterTest.php
2017-12-28 17:36:09 +08:00

49 lines
896 B
PHP

<?php
namespace Test\Unit;
use Test\TestCase;
use Web3\Formatters\Integer;
class IntegerFormatterTest extends TestCase
{
/**
* formatter
*
* @var \Web3\Formatters\Integer
*/
protected $formatter;
/**
* setUp
*
* @return void
*/
public function setUp()
{
parent::setUp();
$this->formatter = new Integer;
}
/**
* testFormat
*
* @return void
*/
public function testFormat()
{
$formatter = $this->formatter;
$hex = $formatter->format('1');
$this->assertEquals($hex, implode('', array_fill(0, 63, '0')) . '1');
$hex = $formatter->format('-1');
$this->assertEquals($hex, implode('', array_fill(0, 64, 'f')));
$hex = $formatter->format('ae');
$this->assertEquals($hex, implode('', array_fill(0, 62, '0')) . 'ae');
}
}