3 * @version $Id: utf8_substr.test.php,v 1.5 2006/09/30 22:51:00 harryf Exp $
8 //--------------------------------------------------------------------
14 require_once(dirname(__FILE__).'/../config.php');
16 //--------------------------------------------------------------------
21 class test_utf8_substr extends UnitTestCase {
23 function test_utf8_substr() {
24 $this->UnitTestCase('utf8_substr()');
28 $str = 'Iñtërnâtiônàlizætiøn';
29 $this->assertEqual(utf8_substr($str,0,2),'Iñ');
32 function testUtf8Two() {
33 $str = 'Iñtërnâtiônàlizætiøn';
34 $this->assertEqual(utf8_substr($str,2,2),'të');
37 function testUtf8Zero() {
38 $str = 'Iñtërnâtiônàlizætiøn';
39 $this->assertEqual(utf8_substr($str,0),'Iñtërnâtiônàlizætiøn');
42 function testUtf8ZeroZero() {
43 $str = 'Iñtërnâtiônàlizætiøn';
44 $this->assertEqual(utf8_substr($str,0,0),'');
47 function testStartGreatThanLength() {
49 $this->assertFalse(utf8_substr($str,4));
52 function testCompareStartGreatThanLength() {
54 $this->assertEqual(utf8_substr($str,4),substr($str,4));
57 function testLengthBeyondString() {
59 $this->assertEqual(utf8_substr($str,1,5),'ñt');
62 function testCompareLengthBeyondString() {
64 $this->assertEqual(utf8_substr($str,1,5),substr($str,1,5));
67 function testStartNegative() {
68 $str = 'Iñtërnâtiônàlizætiøn';
69 $this->assertEqual(utf8_substr($str,-4), 'tiøn');
72 function testLengthNegative() {
73 $str = 'Iñtërnâtiônàlizætiøn';
74 $this->assertEqual(utf8_substr($str,10,-2), 'nàlizæti');
77 function testStartLengthNegative() {
78 $str = 'Iñtërnâtiônàlizætiøn';
79 $this->assertEqual(utf8_substr($str,-4,-2), 'ti');
82 function testLinefeed() {
83 $str = "Iñ\ntërnâtiônàlizætiøn";
84 $this->assertEqual(utf8_substr($str,1,5),"ñ\ntër");
87 function testLongLength() {
88 $str = 'Iñtërnâtiônàlizætiøn';
89 $this->assertEqual(utf8_substr($str,0,15536),'Iñtërnâtiônàlizætiøn');
94 //--------------------------------------------------------------------
99 if (!defined('TEST_RUNNING')) {
100 define('TEST_RUNNING', true);
101 $test = & new test_utf8_substr();
102 $reporter = & getTestReporter();
103 $test->run($reporter);