<?php

declare(strict_types=1);

/*
 * This file is part of the RegexParser package.
 *
 * (c) Younes ENNAJI <younes.ennaji.pro@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace RegexParser\Tests\Unit\ReDoS;

use PHPUnit\Framework\TestCase;
use RegexParser\ReDoS\CharSet;

final class CharSetCoverageTest extends TestCase
{
    public function test_union_returns_empty_for_two_empty_sets(): void
    {
        $result = CharSet::empty()->union(CharSet::empty());

        $this->assertTrue($result->isEmpty());
    }

    public function test_sample_char_returns_null_when_range_is_missing(): void
    {
        $ref = new \ReflectionClass(CharSet::class);
        $set = $ref->newInstanceWithoutConstructor();

        $ref->getProperty('ranges')->setValue($set, [[]]);
        $ref->getProperty('unknown')->setValue($set, false);

        $this->assertNull($set->sampleChar());
    }
}
