1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Ensure we cover all mutations in tests

This commit is contained in:
Aidan Woods 2019-02-22 15:30:00 +00:00
parent 4adbd0b8a7
commit 7f6127f3f8
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
3 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace Erusev\Parsedown\Tests\Parsing;
use Erusev\Parsedown\Parsing\Line;
use PHPUnit\Framework\TestCase;
final class LineTest extends TestCase
{
/**
* @return void
* @throws \PHPUnit\Framework\ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function testLTrimmingBody()
{
$Line = new Line(" \t \t \t \tfoo", 1);
// ltrim only acts on the indent string
$this->assertSame('foo', $Line->ltrimBodyUpto(100));
$this->assertSame(" \t \t \t \tfoo", $Line->ltrimBodyUpto(1));
$this->assertSame("\t \t \t \tfoo", $Line->ltrimBodyUpto(2));
$this->assertSame(" \t \t \tfoo", $Line->ltrimBodyUpto(3));
$this->assertSame("\t \t \tfoo", $Line->ltrimBodyUpto(4));
$this->assertSame(" \t \tfoo", $Line->ltrimBodyUpto(5));
$this->assertSame(" \t \tfoo", $Line->ltrimBodyUpto(6));
$this->assertSame(" \t \tfoo", $Line->ltrimBodyUpto(7));
$this->assertSame(" \t \tfoo", $Line->ltrimBodyUpto(8));
$this->assertSame("\t \tfoo", $Line->ltrimBodyUpto(9));
$this->assertSame(" \tfoo", $Line->ltrimBodyUpto(10));
$this->assertSame(" \tfoo", $Line->ltrimBodyUpto(11));
$this->assertSame(" \tfoo", $Line->ltrimBodyUpto(12));
$this->assertSame(" \tfoo", $Line->ltrimBodyUpto(13));
$this->assertSame("\tfoo", $Line->ltrimBodyUpto(14));
$this->assertSame('foo', $Line->ltrimBodyUpto(15));
$this->assertSame('foo', $Line->ltrimBodyUpto(16));
}
}

View File

@ -83,4 +83,20 @@ final class LinesTest extends TestCase
$this->assertSame($Lines->trailingBlankLines(), 0);
}
/**
* @return void
* @throws \PHPUnit\Framework\ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function testAppendNegativeBlankLines()
{
$Lines = Lines::fromTextLines('foo', 0);
$this->assertSame($Lines->trailingBlankLines(), 0);
$Lines = $Lines->appendingBlankLines(-1);
$this->assertSame($Lines->trailingBlankLines(), 0);
}
}

View File

@ -29,4 +29,14 @@ final class StateTest extends TestCase
$this->assertFalse($UpdatedState->get(StrictMode::class)->isEnabled());
$this->assertFalse($UpdatedState->get(Breaks::class)->isEnabled());
}
/**
* @return void
* @throws \PHPUnit\Framework\ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function testStateCloneVisibility()
{
$this->assertInstanceOf(State::class, clone(new State));
}
}