3 * @version $Id: utf8_substr_replace.test.php,v 1.3 2006/10/17 09:22:14 harryf Exp $
8 //--------------------------------------------------------------------
14 require_once(dirname(__FILE__).'/../config.php');
15 require_once UTF8 . '/substr_replace.php';
17 //--------------------------------------------------------------------
22 class test_utf8_native_substr_replace extends UnitTestCase {
24 function test_utf8_native_substr_replace() {
25 $this->UnitTestCase('utf8_str_split()');
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);
34 function testEmptyString() {
37 $this->assertEqual(utf8_substr_replace($str,'X',8),$replaced);
40 function testNegative() {
42 $replaced = substr_replace($str,'foo',-2,-2);
43 $this->assertEqual(utf8_substr_replace($str,'foo',-2,-2),$replaced);
48 $replaced = substr_replace($str,'foo',0,0);
49 $this->assertEqual(utf8_substr_replace($str,'foo',0,0),$replaced);
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);
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);
66 //--------------------------------------------------------------------
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);