[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 // use no mbstring help here 3 if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1); 4 5 class utf8_substr_test extends DokuWikiTest { 6 7 8 function test1(){ 9 // we test multiple cases here - format: in, offset, length, out 10 $tests = array(); 11 $tests[] = array('asciistring',2,null,'ciistring'); 12 $tests[] = array('asciistring',2,4,'ciis'); 13 $tests[] = array('asciistring',-4,null,'ring'); 14 $tests[] = array('asciistring',2,-4,'ciist'); 15 $tests[] = array('asciistring',-6,-2,'stri'); 16 17 $tests[] = array('живπά우리をあöä',2,null,'вπά우리をあöä'); 18 $tests[] = array('живπά우리をあöä',2,4,'вπά우'); 19 $tests[] = array('живπά우리をあöä',-4,null,'をあöä'); 20 $tests[] = array('живπά우리をあöä',2,-4,'вπά우리'); 21 $tests[] = array('живπά우리をあöä',-6,-2,'우리をあ'); 22 23 foreach($tests as $test){ 24 $this->assertEquals(\dokuwiki\Utf8\PhpString::substr($test[0],$test[1],$test[2]),$test[3]); 25 } 26 } 27 28 function test2_bug891() { 29 // we test multiple cases here - format: in, offset, length, out 30 $tests = array(); 31 32 $str = str_repeat('в',66000).'@@'; 33 $tests[] = array($str, 65600, 1, 'в'); 34 $tests[] = array($str,0,66002,$str); 35 36 foreach($tests as $test){ 37 $this->assertEquals(\dokuwiki\Utf8\PhpString::substr($test[0],$test[1],$test[2]),$test[3]); 38 } 39 } 40 41 } 42 //Setup VIM: ex: et ts=4 :
title
Description
Body
title
Description
Body
title
Description
Body
title
Body