Tagged 0.7.5
[scuttle] / includes / utf8 / tests / cases / utf8_str_split.test.php
1 <?php
2 /**
3 * @version $Id: utf8_str_split.test.php,v 1.2 2006/02/25 14:52:18 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 . '/str_split.php';
16
17 //--------------------------------------------------------------------
18 /**
19 * @package utf8
20 * @subpackage Tests
21 */
22 class test_utf8_str_split extends UnitTestCase {
23
24     function test_utf8_str_split() {
25         $this->UnitTestCase('utf8_str_split()');
26     }
27     
28     function testSplitOneChar() {
29         $str = 'Iñtërnâtiônàlizætiøn';
30         $array = array(
31             'I','ñ','t','ë','r','n','â','t','i','ô','n','à','l','i',
32             'z','æ','t','i','ø','n',
33         );
34         $this->assertEqual(utf8_str_split($str),$array);
35     }
36     
37     function testSplitFiveChars() {
38         $str = 'Iñtërnâtiônàlizætiøn';
39         $array = array(
40             'Iñtër','nâtiô','nàliz','ætiøn',
41         );
42         $this->assertEqual(utf8_str_split($str,5),$array);
43     }
44     
45     function testSplitSixChars() {
46         $str = 'Iñtërnâtiônàlizætiøn';
47         $array = array(
48             'Iñtërn','âtiônà', 'lizæti','øn',
49         );
50         $this->assertEqual(utf8_str_split($str,6),$array);
51     }
52     
53     function testSplitLong() {
54         $str = 'Iñtërnâtiônàlizætiøn';
55         $array = array(
56             'Iñtërnâtiônàlizætiøn',
57         );
58         $this->assertEqual(utf8_str_split($str,40),$array);
59     }
60     
61     function testSplitNewline() {
62         $str = "Iñtërn\nâtiônàl\nizætiøn\n";
63         $array = array(
64             'I','ñ','t','ë','r','n',"\n",'â','t','i','ô','n','à','l',"\n",'i',
65             'z','æ','t','i','ø','n',"\n",
66         );
67         $this->assertEqual(utf8_str_split($str),$array);
68     }
69     
70 }
71
72 //--------------------------------------------------------------------
73 /**
74 * @package utf8
75 * @subpackage Tests
76 */
77 if (!defined('TEST_RUNNING')) {
78     define('TEST_RUNNING', true);
79     $test = &new test_utf8_str_split();
80     $reporter = & getTestReporter();
81     $test->run($reporter);
82 }

Benjamin Mako Hill || Want to submit a patch?