index/tests/Base62Test.php
flashwave 4a40868f58 Added generic IntegerBaseConverter implementation and merged Base62 class with XNumber.
The Base62 implementation was always a bit misleading because both UriBase64 and Base32 handle any binary data whereas Base62 was only for converting integers.
This shake-up should lessen that confusion.
2024-07-31 19:05:41 +00:00

36 lines
838 B
PHP

<?php
// Base62Test.php
// Created: 2022-01-28
// Updated: 2024-07-31
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Index\XNumber;
#[CoversClass(XNumber::class)]
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)
$this->assertEquals($test[1], XNumber::fromBase62($test[0]));
}
public function testEncode(): void {
foreach(self::TESTS as $test)
$this->assertEquals($test[0], XNumber::toBase62($test[1]));
}
}