PHP and Javascript implementations of a simple markdown parser
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. use PHPUnit\Framework\TestCase;
  4. require_once __DIR__ . '/../php/markdown.php';
  5. final class UtilsTests extends TestCase {
  6. public function test_stripIndent() {
  7. $this->assertSame('', MDUtils::stripIndent(''));
  8. $this->assertSame('', MDUtils::stripIndent(' '));
  9. $this->assertSame('foo', MDUtils::stripIndent('foo'));
  10. $this->assertSame('foo', MDUtils::stripIndent(' foo'));
  11. $this->assertSame('foo', MDUtils::stripIndent(' foo'));
  12. $this->assertSame('foo', MDUtils::stripIndent(' foo'));
  13. $this->assertSame('foo', MDUtils::stripIndent(' foo'));
  14. $this->assertSame(' foo', MDUtils::stripIndent(' foo'));
  15. $this->assertSame('foo', MDUtils::stripIndent("\tfoo"));
  16. $this->assertSame("\tfoo", MDUtils::stripIndent("\t\tfoo"));
  17. $this->assertSame('foo', MDUtils::stripIndent("\t\tfoo", 2));
  18. $this->assertSame('foo', MDUtils::stripIndent(' foo', 2));
  19. }
  20. public function test_countIndents() {
  21. $this->assertSame(0, MDUtils::countIndents(''));
  22. $this->assertSame(1, MDUtils::countIndents(' '));
  23. $this->assertSame(1, MDUtils::countIndents(' '));
  24. $this->assertSame(0, MDUtils::countIndents('foo'));
  25. $this->assertSame(0, MDUtils::countIndents('foo'));
  26. $this->assertSame(1, MDUtils::countIndents(' foo'));
  27. $this->assertSame(1, MDUtils::countIndents(' foo'));
  28. $this->assertSame(1, MDUtils::countIndents(' foo'));
  29. $this->assertSame(1, MDUtils::countIndents(' foo'));
  30. $this->assertSame(2, MDUtils::countIndents(' foo'));
  31. $this->assertSame(1, MDUtils::countIndents("\tfoo"));
  32. $this->assertSame(2, MDUtils::countIndents("\t\tfoo"));
  33. $this->assertSame(0, MDUtils::countIndents('', true));
  34. $this->assertSame(0, MDUtils::countIndents(' ', true));
  35. $this->assertSame(1, MDUtils::countIndents(' ', true));
  36. $this->assertSame(0, MDUtils::countIndents('foo', true));
  37. $this->assertSame(0, MDUtils::countIndents(' foo', true));
  38. $this->assertSame(0, MDUtils::countIndents(' foo', true));
  39. $this->assertSame(0, MDUtils::countIndents(' foo', true));
  40. $this->assertSame(1, MDUtils::countIndents(' foo', true));
  41. $this->assertSame(1, MDUtils::countIndents(' foo', true));
  42. $this->assertSame(1, MDUtils::countIndents("\tfoo", true));
  43. $this->assertSame(2, MDUtils::countIndents("\t\tfoo", true));
  44. }
  45. }
  46. ?>