]> projects.mako.cc - scuttle/blob - includes/utf8/tests/cases/utf8_substr_replace.test.php
updated readme with information on a series of bugs I know exist
[scuttle] / includes / utf8 / tests / cases / utf8_substr_replace.test.php
1 <?php
2 /**
3 * @version $Id: utf8_substr_replace.test.php,v 1.3 2006/10/17 09:22:14 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 . '/substr_replace.php';
16
17 //--------------------------------------------------------------------
18 /**
19 * @package utf8
20 * @subpackage Tests
21 */
22 class test_utf8_native_substr_replace extends UnitTestCase {
23
24     function test_utf8_native_substr_replace() {
25         $this->UnitTestCase('utf8_str_split()');
26     }
27     
28     function testReplaceStart() {
29         $str = 'Iñtërnâtiônàlizætiøn';
30         $replaced = 'IñtërnâtX';
31         $this->assertEqual(utf8_substr_replace($str,'X',8),$replaced);
32     }
33     
34     function testEmptyString() {
35         $str = '';
36         $replaced = 'X';
37         $this->assertEqual(utf8_substr_replace($str,'X',8),$replaced);
38     }
39     
40     function testNegative() {
41         $str = 'testing';
42         $replaced = substr_replace($str,'foo',-2,-2);
43         $this->assertEqual(utf8_substr_replace($str,'foo',-2,-2),$replaced);
44     }
45     
46     function testZero() {
47         $str = 'testing';
48         $replaced = substr_replace($str,'foo',0,0);
49         $this->assertEqual(utf8_substr_replace($str,'foo',0,0),$replaced);
50     }
51     
52     function testLinefeed() {
53         $str = "Iñ\ntërnâtiônàlizætiøn";
54         $replaced = "Iñ\ntërnâtX";
55         $this->assertEqual(utf8_substr_replace($str,'X',9),$replaced);
56     }
57     
58     function testLinefeedReplace() {
59         $str = "Iñ\ntërnâtiônàlizætiøn";
60         $replaced = "Iñ\ntërnâtX\nY";
61         $this->assertEqual(utf8_substr_replace($str,"X\nY",9),$replaced);
62     }
63     
64 }
65
66 //--------------------------------------------------------------------
67 /**
68 * @package utf8
69 * @subpackage Tests
70 */
71 if (!defined('TEST_RUNNING')) {
72     define('TEST_RUNNING', true);
73     $test = &new test_utf8_native_substr_replace();
74     $reporter = & getTestReporter();
75     $test->run($reporter);
76 }

Benjamin Mako Hill || Want to submit a patch?