Changeset View
Changeset View
Standalone View
Standalone View
src/utils/__tests__/PhutilUTF8TestCase.php
| Show First 20 Lines • Show All 603 Lines • ▼ Show 20 Lines | public function testUTF8BMPSegfaults() { | ||||
| // This test case fails by segfaulting, or passes by not segfaulting. See | // This test case fails by segfaulting, or passes by not segfaulting. See | ||||
| // the function implementation for details. | // the function implementation for details. | ||||
| $input = str_repeat("\xEF\xBF\xBF", 1024 * 32); | $input = str_repeat("\xEF\xBF\xBF", 1024 * 32); | ||||
| phutil_is_utf8_with_only_bmp_characters($input); | phutil_is_utf8_with_only_bmp_characters($input); | ||||
| $this->assertTrue(true); | $this->assertTrue(true); | ||||
| } | } | ||||
| public function testCJK() { | |||||
| $map = array( | |||||
| '' => false, | |||||
| 'a' => false, | |||||
| '.' => false, | |||||
| "\xE2\x98\x83" => false, | |||||
| "\xE5\xA0\xB1" => true, | |||||
| ); | |||||
| foreach ($map as $input => $expect) { | |||||
| $actual = phutil_utf8_is_cjk($input); | |||||
| $this->assertEqual($expect, $actual, pht('CJK: "%s"', $input)); | |||||
| } | |||||
| } | |||||
| public function testUTF8BMP() { | public function testUTF8BMP() { | ||||
| $tests = array( | $tests = array( | ||||
| '' => array( | '' => array( | ||||
| true, | true, | ||||
| true, | true, | ||||
| pht('empty string'), | pht('empty string'), | ||||
| ), | ), | ||||
| 'a' => array( | 'a' => array( | ||||
| ▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines | |||||