Strings.trim().phpt 493 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Strings::trim()
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Strings;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. Assert::same('x', Strings::trim(" \t\n\r\x00\x0B\u{A0}x"));
  10. Assert::same('a b', Strings::trim(' a b '));
  11. Assert::same(' a b ', Strings::trim(' a b ', ''));
  12. Assert::same('e', Strings::trim("\u{158}e-", "\u{158}-")); // Ře-
  13. Assert::exception(
  14. fn() => Strings::trim("\xC2x\xA0"),
  15. Nette\Utils\RegexpException::class,
  16. null,
  17. );