Beispiel #1
0
 function Unicode()
 {
     $this->set('title', 'Unicode');
     $str = 'אני יכול לאכול זכוכית וזה לא מזיק לי';
     $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text'));
     $this->expect(UTF::strlen($str) == 36, 'String length evaluated correctly', 'String length is wrong: ' . UTF::strlen($str));
     $this->expect(UTF::substr($str, 0, 5) == 'אני י', 'Substring at offset 0 (length 5) is correct', 'Substring at offset 0 (length 5) is wrong: ' . UTF::substr($str, 0, 5));
     $this->expect(UTF::substr($str, 12) == 'ול זכוכית וזה לא מזיק לי', 'Substring at offset 12 (unspecified length) is correct', 'Substring at offset 12 (unspecified length) is wrong: ' . UTF::substr($str, 12));
     $this->expect(UTF::substr($str, 3, 4) == ' יכו', 'Substring at offset 3 (length 4) is correct', 'Substring at offset 3 (length 4) is wrong: ' . UTF::substr($str, 3, 4));
     $this->expect(UTF::substr('', 7) == FALSE, 'Substring of empty string returns FALSE', 'Substring of empty string returns non-boolean value: ' . UTF::substr('', 0));
     $this->expect(UTF::substr($str, -5) == 'יק לי', 'Substring at negative offset is correct', 'Substring at negative offset is wrong: ' . UTF::substr($str, -5));
     $this->expect(UTF::strpos($str, 'ת וזה') == 20, 'String position detected accurately', 'String position detected incorrectly');
     $this->expect(UTF::strpos($str, 'xyz') === FALSE, 'Non-existent substring returns FALSE', 'Non-existent substring returns non-boolean value: ' . UTF::strpos($str, 'xyz'));
     $this->expect(UTF::strrpos($str, 'כ') == 18, 'String position (right-to-left) detected accurately', 'String position (right-to-left) detected incorrectly');
     $this->expect(UTF::strstr($str, 'לא מ', TRUE) == 'אני יכול לאכול זכוכית וזה ', 'Substring search returns correct value', 'Substring search failed: ' . UTF::strstr($str, 'לא מ', TRUE));
     $this->expect(UTF::strstr($str, 'לא מזי') == 'לא מזיק לי', 'Substring search returns correct latent value', 'Substring search failed: ' . UTF::strstr($str, 'לא מ'));
     $this->expect(UTF::substr_count($str, 'כו') == 3, 'Substring count is correct', 'Substring count is incorrect');
     echo $this->render('basic/results.htm');
 }