[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> utf8_unicode.test.php (source)

   1  <?php
   2  
   3  // use no mbstring help here
   4  if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
   5  
   6  class utf8_unicode_test extends DokuWikiTest {
   7  
   8      function test_from_1byte(){
   9          $in  = 'a';
  10          $out = array(97);
  11          $this->assertEquals(\dokuwiki\Utf8\Unicode::fromUtf8($in),$out);
  12      }
  13  
  14      function test_from_2byte(){
  15          $in  = "\xc3\xbc";
  16          $out = array(252);
  17          $this->assertEquals(\dokuwiki\Utf8\Unicode::fromUtf8($in),$out);
  18      }
  19  
  20      function test_from_3byte(){
  21          $in  = "\xe2\x99\x8a";
  22          $out = array(9802);
  23          $this->assertEquals(\dokuwiki\Utf8\Unicode::fromUtf8($in),$out);
  24      }
  25  
  26      function test_from_4byte(){
  27          $in  = "\xf4\x80\x80\x81";
  28          $out = array(1048577);
  29          $this->assertEquals(\dokuwiki\Utf8\Unicode::fromUtf8($in),$out);
  30      }
  31  
  32      function test_to_1byte(){
  33          $out  = 'a';
  34          $in = array(97);
  35          $this->assertEquals(\dokuwiki\Utf8\Unicode::toUtf8($in),$out);
  36      }
  37  
  38      function test_to_2byte(){
  39          $out  = "\xc3\xbc";
  40          $in = array(252);
  41          $this->assertEquals(\dokuwiki\Utf8\Unicode::toUtf8($in),$out);
  42      }
  43  
  44      function test_to_3byte(){
  45          $out  = "\xe2\x99\x8a";
  46          $in = array(9802);
  47          $this->assertEquals(\dokuwiki\Utf8\Unicode::toUtf8($in),$out);
  48      }
  49  
  50      function test_to_4byte(){
  51          $out  = "\xf4\x80\x80\x81";
  52          $in = array(1048577);
  53          $this->assertEquals(\dokuwiki\Utf8\Unicode::toUtf8($in),$out);
  54      }
  55  
  56  }
  57  
  58  //Setup VIM: ex: et ts=4 :