File: Strings.chr%28%29.phpt

package info (click to toggle)
php-nette-utils 4.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,420 kB
  • sloc: php: 4,069; xml: 12; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

/**
 * Test: Nette\Utils\Strings::chr()
 */

declare(strict_types=1);

use Nette\Utils\Strings;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';


Assert::same("\x00", Strings::chr(0x000000));
Assert::same("\x7F", Strings::chr(0x00007F));
Assert::same("\u{80}", Strings::chr(0x000080));
Assert::same("\u{7FF}", Strings::chr(0x0007FF));
Assert::same("\u{800}", Strings::chr(0x000800));
Assert::same("\u{D7FF}", Strings::chr(0x00D7FF));
Assert::same("\u{E000}", Strings::chr(0x00E000));
Assert::same("\u{FFFF}", Strings::chr(0x00FFFF));
Assert::same("\u{10000}", Strings::chr(0x010000));
Assert::same("\u{10FFFF}", Strings::chr(0x10FFFF));

foreach ([-1, 0xD800, 0xDFFF, 0x110000] as $code) {
	Assert::exception(
		fn() => Strings::chr($code),
		Nette\InvalidArgumentException::class,
		'Code point must be in range 0x0 to 0xD7FF or 0xE000 to 0x10FFFF.',
	);
}