]> projects.mako.cc - scuttle/blob - includes/utf8/tests/cases/utf8_strpos.test.php
updated readme with information on a series of bugs I know exist
[scuttle] / includes / utf8 / tests / cases / utf8_strpos.test.php
1 <?php
2 /**
3 * @version $Id: utf8_strpos.test.php,v 1.2 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_strpos extends UnitTestCase {
22
23     function test_utf8_strpos() {
24         $this->UnitTestCase('utf8_strpos()');
25     }
26     
27     function testUtf8() {
28         $str = 'Iñtërnâtiônàlizætiøn';
29         $this->assertEqual(utf8_strpos($str,'â'),6);
30     }
31     
32     function testUtf8Offset() {
33         $str = 'Iñtërnâtiônàlizætiøn';
34         $this->assertEqual(utf8_strpos($str,'n',11),19);
35     }
36     
37     function testUtf8Invalid() {
38         $str = "Iñtërnâtiôn\xe9àlizætiøn";
39         $this->assertEqual(utf8_strpos($str,'æ'),15);
40     }
41     
42     function testAscii() {
43         $str = 'ABC 123';
44         $this->assertEqual(utf8_strpos($str,'B'),1);
45     }
46     
47     function testVsStrpos() {
48         $str = 'ABC 123 ABC';
49         $this->assertEqual(utf8_strpos($str,'B',3),strpos($str,'B',3));
50     }
51     
52     function testEmptyStr() {
53         $str = '';
54         $this->assertFalse(utf8_strpos($str,'x'));
55     }
56     
57 }
58
59 //--------------------------------------------------------------------
60 /**
61 * @package utf8
62 * @subpackage Tests
63 */
64 if (!defined('TEST_RUNNING')) {
65     define('TEST_RUNNING', true);
66     $test = &new test_utf8_strpos();
67     $reporter = & getTestReporter();
68     $test->run($reporter);
69 }

Benjamin Mako Hill || Want to submit a patch?