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