[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/cases/inc/ -> utf8_substr.test.php (source)

   1  <?php
   2  // use no mbstring help here
   3  if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
   4  require_once  DOKU_INC.'inc/utf8.php';
   5  
   6  class utf8_substr_test extends UnitTestCase {
   7  
   8  
   9      function test1(){
  10          // we test multiple cases here - format: in, offset, length, out
  11          $tests   = array();
  12          $tests[] = array('asciistring',2,null,'ciistring');
  13          $tests[] = array('asciistring',2,4,'ciis');
  14          $tests[] = array('asciistring',-4,null,'ring');
  15          $tests[] = array('asciistring',2,-4,'ciist');
  16          $tests[] = array('asciistring',-6,-2,'stri');
  17  
  18          $tests[] = array('живπά우리をあöä',2,null,'вπά우리をあöä');
  19          $tests[] = array('живπά우리をあöä',2,4,'вπά우');
  20          $tests[] = array('живπά우리をあöä',-4,null,'をあöä');
  21          $tests[] = array('живπά우리をあöä',2,-4,'вπά우리');
  22          $tests[] = array('живπά우리をあöä',-6,-2,'우리をあ');
  23  
  24          foreach($tests as $test){
  25              $this->assertEqual(utf8_substr($test[0],$test[1],$test[2]),$test[3]);
  26          }
  27      }
  28  
  29      function test2_bug891() {
  30          // we test multiple cases here - format: in, offset, length, out
  31          $tests   = array();
  32  
  33          $str = str_repeat('в',66000).'@@';
  34          $tests[] = array($str, 65600, 1, 'в');
  35          $tests[] = array($str,0,66002,$str);
  36  
  37          foreach($tests as $test){
  38              $this->assertEqual(utf8_substr($test[0],$test[1],$test[2]),$test[3]);
  39          }
  40      }
  41  
  42  }
  43  //Setup VIM: ex: et ts=4 enc=utf-8 :


Generated: Wed Dec 3 01:30:02 2008 Cross-referenced by PHPXref 0.7