endtoend-test-psl/tests/Psl/Math/BaseConvertTest.php

81 lines
1.4 KiB
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Math;
use PHPUnit\Framework\TestCase;
2019-12-26 21:03:29 +01:00
use Psl\Math;
2019-12-24 01:52:07 +01:00
class BaseConvertTest extends TestCase
{
2019-12-26 21:03:29 +01:00
/**
* @dataProvider provideData
*/
public function testBaseConvert(string $expected, string $value, int $from, int $to): void
{
self::assertSame($expected, Math\base_convert($value, $from, $to));
}
public function provideData(): array
{
return [
[
'2',
'10',
2,
16
],
[
'2',
'10',
2,
10
],
[
'f',
'15',
10,
16
],
[
'10',
'2',
16,
2
],
[
'1010101111001',
'5497',
10,
2
],
[
'48p',
'1010101111001',
2,
36
],
[
'pphlmw9v',
'2014587925987',
10,
36
],
[
'zik0zj',
(string) Math\INT32_MAX,
10,
36
]
];
}
2019-12-24 01:52:07 +01:00
}