2022-09-13 13:13:11 +00:00
|
|
|
<?php
|
|
|
|
// Base62Test.php
|
|
|
|
// Created: 2022-01-28
|
2024-12-22 02:02:53 +00:00
|
|
|
// Updated: 2024-12-22
|
2022-09-13 13:13:11 +00:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2024-07-31 18:12:46 +00:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
2024-07-31 19:05:41 +00:00
|
|
|
use Index\XNumber;
|
2022-09-13 13:13:11 +00:00
|
|
|
|
2024-07-31 19:05:41 +00:00
|
|
|
#[CoversClass(XNumber::class)]
|
2022-09-13 13:13:11 +00:00
|
|
|
final class Base62Test extends TestCase {
|
|
|
|
public const TESTS = [
|
|
|
|
['aaaaaa', 9311514030],
|
|
|
|
['Soap', 12962613],
|
2024-12-22 02:02:53 +00:00
|
|
|
['0', 0],
|
2022-09-13 13:13:11 +00:00
|
|
|
['1', 1],
|
|
|
|
['kPH', 80085],
|
|
|
|
['UC', 3510],
|
|
|
|
['p', 25],
|
|
|
|
['6zi', 25252],
|
|
|
|
['1ly7vk', 1234567890],
|
2024-12-22 02:02:53 +00:00
|
|
|
['15vjOLmUu1', 14739082838046309],
|
2022-09-13 13:13:11 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
public function testDecode(): void {
|
2024-12-22 02:02:53 +00:00
|
|
|
$this->assertEquals(0, XNumber::fromBase62(''));
|
2022-09-13 13:13:11 +00:00
|
|
|
foreach(self::TESTS as $test)
|
2024-07-31 19:05:41 +00:00
|
|
|
$this->assertEquals($test[1], XNumber::fromBase62($test[0]));
|
2022-09-13 13:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testEncode(): void {
|
|
|
|
foreach(self::TESTS as $test)
|
2024-07-31 19:05:41 +00:00
|
|
|
$this->assertEquals($test[0], XNumber::toBase62($test[1]));
|
2022-09-13 13:13:11 +00:00
|
|
|
}
|
|
|
|
}
|