| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- declare(strict_types=1);
-
- use PHPUnit\Framework\TestCase;
-
- require_once __DIR__ . '/../php/markdown.php';
-
- final class UtilsTests extends TestCase {
- public function test_stripIndent() {
- $this->assertSame('', MDUtils::stripIndent(''));
- $this->assertSame('', MDUtils::stripIndent(' '));
- $this->assertSame('foo', MDUtils::stripIndent('foo'));
- $this->assertSame('foo', MDUtils::stripIndent(' foo'));
- $this->assertSame('foo', MDUtils::stripIndent(' foo'));
- $this->assertSame('foo', MDUtils::stripIndent(' foo'));
- $this->assertSame('foo', MDUtils::stripIndent(' foo'));
- $this->assertSame(' foo', MDUtils::stripIndent(' foo'));
- $this->assertSame('foo', MDUtils::stripIndent("\tfoo"));
- $this->assertSame("\tfoo", MDUtils::stripIndent("\t\tfoo"));
- $this->assertSame('foo', MDUtils::stripIndent("\t\tfoo", 2));
- $this->assertSame('foo', MDUtils::stripIndent(' foo', 2));
- }
-
- public function test_countIndents() {
- $this->assertSame(0, MDUtils::countIndents(''));
- $this->assertSame(1, MDUtils::countIndents(' '));
- $this->assertSame(1, MDUtils::countIndents(' '));
- $this->assertSame(0, MDUtils::countIndents('foo'));
- $this->assertSame(0, MDUtils::countIndents('foo'));
- $this->assertSame(1, MDUtils::countIndents(' foo'));
- $this->assertSame(1, MDUtils::countIndents(' foo'));
- $this->assertSame(1, MDUtils::countIndents(' foo'));
- $this->assertSame(1, MDUtils::countIndents(' foo'));
- $this->assertSame(2, MDUtils::countIndents(' foo'));
- $this->assertSame(1, MDUtils::countIndents("\tfoo"));
- $this->assertSame(2, MDUtils::countIndents("\t\tfoo"));
-
- $this->assertSame(0, MDUtils::countIndents('', true));
- $this->assertSame(0, MDUtils::countIndents(' ', true));
- $this->assertSame(1, MDUtils::countIndents(' ', true));
- $this->assertSame(0, MDUtils::countIndents('foo', true));
- $this->assertSame(0, MDUtils::countIndents(' foo', true));
- $this->assertSame(0, MDUtils::countIndents(' foo', true));
- $this->assertSame(0, MDUtils::countIndents(' foo', true));
- $this->assertSame(1, MDUtils::countIndents(' foo', true));
- $this->assertSame(1, MDUtils::countIndents(' foo', true));
- $this->assertSame(1, MDUtils::countIndents("\tfoo", true));
- $this->assertSame(2, MDUtils::countIndents("\t\tfoo", true));
- }
- }
- ?>
|