2022-09-13 13:13:11 +00:00
|
|
|
<?php
|
|
|
|
// Base62Test.php
|
|
|
|
// Created: 2022-01-28
|
2023-07-21 21:47:41 +00:00
|
|
|
// Updated: 2023-07-21
|
2022-09-13 13:13:11 +00:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2023-07-21 21:47:41 +00:00
|
|
|
use Index\Serialisation\Base62;
|
2022-09-13 13:13:11 +00:00
|
|
|
|
|
|
|
/**
|
2023-07-21 21:47:41 +00:00
|
|
|
* @covers Base62
|
2022-09-13 13:13:11 +00:00
|
|
|
*/
|
|
|
|
final class Base62Test extends TestCase {
|
|
|
|
public const TESTS = [
|
|
|
|
['aaaaaa', 9311514030],
|
|
|
|
['Soap', 12962613],
|
|
|
|
['', 0],
|
|
|
|
['1', 1],
|
|
|
|
['kPH', 80085],
|
|
|
|
['UC', 3510],
|
|
|
|
['p', 25],
|
|
|
|
['6zi', 25252],
|
|
|
|
['1ly7vk', 1234567890],
|
|
|
|
];
|
|
|
|
|
|
|
|
public function testDecode(): void {
|
|
|
|
foreach(self::TESTS as $test)
|
2023-07-21 21:47:41 +00:00
|
|
|
$this->assertEquals($test[1], Base62::decode($test[0]));
|
2022-09-13 13:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testEncode(): void {
|
|
|
|
foreach(self::TESTS as $test)
|
2023-07-21 21:47:41 +00:00
|
|
|
$this->assertEquals($test[0], Base62::encode($test[1]));
|
2022-09-13 13:13:11 +00:00
|
|
|
}
|
|
|
|
}
|