]> projects.mako.cc - scuttle/blob - includes/utf8/tests/cases/utf8_specials.test.php
Merge branch 'master' of https://github.com/underhilllabs/scuttle
[scuttle] / includes / utf8 / tests / cases / utf8_specials.test.php
1 <?php
2 /**
3 * @version $Id: utf8_specials.test.php,v 1.2 2006/10/17 09:09:13 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 . '/utils/unicode.php';
16 require_once UTF8 . '/utils/specials.php';
17
18 //--------------------------------------------------------------------
19 /**
20 * @package utf8
21 * @subpackage Tests
22 */
23 class test_utf8_is_word_chars extends UnitTestCase {
24
25     function test_utf8_is_word_chars() {
26         $this->UnitTestCase('test_utf8_is_word_chars()');
27     }
28     
29     function testEmptyString() {
30         $this->assertTrue(utf8_is_word_chars(''));
31     }
32     
33     function testAllWordChars() {
34         $this->assertTrue(utf8_is_word_chars('HelloWorld'));
35     }
36     
37     function testSpecials() {
38         $str = 'Hello ' .
39             chr(0xe0 | (0x2234 >> 12)) .
40             chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
41             chr(0x80 | (0x2234 & 0x003f)) .
42             ' World';
43         $this->assertFalse(utf8_is_word_chars($str));
44     }
45     
46 }
47
48 //--------------------------------------------------------------------
49 /**
50 * @package utf8
51 * @subpackage Tests
52 */
53 class test_utf8_strip_specials extends UnitTestCase {
54
55     function test_utf8_strip_specials() {
56         $this->UnitTestCase('test_utf8_strip_specials()');
57     }
58     
59     function testEmptyString() {
60         $this->assertEqual(utf8_strip_specials(''),'');
61     }
62     
63     function testStrip() {
64         $str = 'Hello ' .
65             chr(0xe0 | (0x2234 >> 12)) .
66             chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
67             chr(0x80 | (0x2234 & 0x003f)) .
68             ' World';
69         $this->assertEqual(utf8_strip_specials($str),'HelloWorld');
70     }
71     
72 }
73
74 //--------------------------------------------------------------------
75 /**
76 * @package utf8
77 * @subpackage Tests
78 */
79 if (!defined('TEST_RUNNING')) {
80     define('TEST_RUNNING', true);
81     $test = &new GroupTest('utf8_ascii');
82     $test->addTestCase(new test_utf8_strip_specials());
83     $test->addTestCase(new test_utf8_is_word_chars());
84     $reporter = & getTestReporter();
85     $test->run($reporter);
86 }

Benjamin Mako Hill || Want to submit a patch?