Tagged 0.7.5
[scuttle] / includes / utf8 / tests / cases / utf8_strrpos.test.php
1 <?php
2 /**
3 * @version $Id: utf8_strrpos.test.php,v 1.3 2006/02/24 23:33:10 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
16 //--------------------------------------------------------------------
17 /**
18 * @package utf8
19 * @subpackage Tests
20 */
21 class test_utf8_strrpos extends UnitTestCase {
22
23     function test_utf8_strrpos() {
24         $this->UnitTestCase('utf8_strrpos()');
25     }
26     
27     function testUtf8() {
28         $str = 'Iñtërnâtiônàlizætiøn';
29         $this->assertEqual(utf8_strrpos($str,'i'),17);
30     }
31     
32     function testUtf8Offset() {
33         $str = 'Iñtërnâtiônàlizætiøn';
34         $this->assertEqual(utf8_strrpos($str,'n',11),19);
35     }
36     
37     function testUtf8Invalid() {
38         $str = "Iñtërnâtiôn\xe9àlizætiøn";
39         $this->assertEqual(utf8_strrpos($str,'æ'),15);
40     }
41     
42     function testAscii() {
43         $str = 'ABC ABC';
44         $this->assertEqual(utf8_strrpos($str,'B'),5);
45     }
46     
47     function testVsStrpos() {
48         $str = 'ABC 123 ABC';
49         $this->assertEqual(utf8_strrpos($str,'B'),strrpos($str,'B'));
50     }
51     
52     function testEmptyStr() {
53         $str = '';
54         $this->assertFalse(utf8_strrpos($str,'x'));
55     }
56     
57     function testLinefeed() {
58         $str = "Iñtërnâtiônàlizætiø\nn";
59         $this->assertEqual(utf8_strrpos($str,'i'),17);
60     }
61     
62     function testLinefeedSearch() {
63         $str = "Iñtërnâtiônàlizætiø\nn";
64         $this->assertEqual(utf8_strrpos($str,"\n"),19);
65     }
66 }
67
68 //--------------------------------------------------------------------
69 /**
70 * @package utf8
71 * @subpackage Tests
72 */
73 if (!defined('TEST_RUNNING')) {
74     define('TEST_RUNNING', true);
75     $test = &new test_utf8_strrpos();
76     $reporter = & getTestReporter();
77     $test->run($reporter);
78 }

Benjamin Mako Hill || Want to submit a patch?