fromRandom example

use Symfony\Component\String\Exception\InvalidArgumentException;

class ByteStringTest extends AbstractAsciiTestCase
{
    protected static function createFromString(string $string): AbstractString
    {
        return new ByteString($string);
    }

    public function testFromRandom()
    {
        $random = ByteString::fromRandom(32);

        self::assertSame(32, $random->length());
        foreach ($random->chunk() as $char) {
            self::assertNotNull((new ByteString('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'))->indexOf($char));
        }
    }

    public function testFromRandomWithSpecificChars()
    {
        $random = ByteString::fromRandom(32, 'abc');

        
Home | Imprint | This part of the site doesn't use cookies.