]> projects.mako.cc - scuttle/blob - includes/utf8/tests/cases/utf8_unicode.test.php
- Override privacy status on bookmark file import, if specified (i.e. Delicious)
[scuttle] / includes / utf8 / tests / cases / utf8_unicode.test.php
1 <?php
2 /**
3 * @version $Id: utf8_unicode.test.php,v 1.1 2006/10/17 09:58:29 harryf Exp $
4 * @package utf8
5 * @subpackage Tests
6 */
7
8 //--------------------------------------------------------------------
9 /**
10 * Includes
11 * @package utf8
12 * @subpackage Tests
13 */
14 require_once(dirname(__FILE__).'/../config.php');
15 require_once UTF8 . '/utils/unicode.php';
16
17 //--------------------------------------------------------------------
18 /**
19 * @package utf8
20 * @subpackage Tests
21 */
22 class test_utf8_to_unicode extends UnitTestCase {
23
24     function test_utf8_to_unicode() {
25         $this->UnitTestCase('test_utf8_to_unicode()');
26     }
27     
28     function testEmptyString() {
29         $this->assertEqual(utf8_to_unicode(''),array());
30     }
31     
32     function testString() {
33         
34         $unicode = array();
35         $unicode[0] = 73;
36         $unicode[1] = 241;
37         $unicode[2] = 116;
38         $unicode[3] = 235;
39         $unicode[4] = 114;
40         $unicode[5] = 110;
41         $unicode[6] = 226;
42         $unicode[7] = 116;
43         $unicode[8] = 105;
44         $unicode[9] = 244;
45         $unicode[10] = 110;
46         $unicode[11] = 224;
47         $unicode[12] = 108;
48         $unicode[13] = 105;
49         $unicode[14] = 122;
50         $unicode[15] = 230;
51         $unicode[16] = 116;
52         $unicode[17] = 105;
53         $unicode[18] = 248;
54         $unicode[19] = 110;
55         
56         $this->assertEqual(utf8_to_unicode('Iñtërnâtiônàlizætiøn'), $unicode);
57     }
58     
59 }
60
61 //--------------------------------------------------------------------
62 /**
63 * @package utf8
64 * @subpackage Tests
65 */
66 class test_utf8_from_unicode extends UnitTestCase {
67
68     function test_utf8_strip_specials() {
69         $this->UnitTestCase('test_utf8_strip_specials()');
70     }
71     
72     function testEmptyArray() {
73         $this->assertEqual(utf8_from_unicode(array()),'');
74     }
75     
76     function testArray() {
77         
78         $unicode = array();
79         $unicode[0] = 73;
80         $unicode[1] = 241;
81         $unicode[2] = 116;
82         $unicode[3] = 235;
83         $unicode[4] = 114;
84         $unicode[5] = 110;
85         $unicode[6] = 226;
86         $unicode[7] = 116;
87         $unicode[8] = 105;
88         $unicode[9] = 244;
89         $unicode[10] = 110;
90         $unicode[11] = 224;
91         $unicode[12] = 108;
92         $unicode[13] = 105;
93         $unicode[14] = 122;
94         $unicode[15] = 230;
95         $unicode[16] = 116;
96         $unicode[17] = 105;
97         $unicode[18] = 248;
98         $unicode[19] = 110;
99         
100         $this->assertEqual(utf8_from_unicode($unicode), 'Iñtërnâtiônàlizætiøn');
101     }
102     
103 }
104
105 //--------------------------------------------------------------------
106 /**
107 * @package utf8
108 * @subpackage Tests
109 */
110 if (!defined('TEST_RUNNING')) {
111     define('TEST_RUNNING', true);
112     $test = &new GroupTest('utf8_ascii');
113     $test->addTestCase(new test_utf8_to_unicode());
114     $test->addTestCase(new test_utf8_from_unicode());
115     $reporter = & getTestReporter();
116     $test->run($reporter);
117 }

Benjamin Mako Hill || Want to submit a patch?