3 * @version $Id: utf8_specials.test.php,v 1.2 2006/10/17 09:09:13 harryf Exp $
8 //--------------------------------------------------------------------
14 require_once(dirname(__FILE__).'/../config.php');
15 require_once UTF8 . '/utils/unicode.php';
16 require_once UTF8 . '/utils/specials.php';
18 //--------------------------------------------------------------------
23 class test_utf8_is_word_chars extends UnitTestCase {
25 function test_utf8_is_word_chars() {
26 $this->UnitTestCase('test_utf8_is_word_chars()');
29 function testEmptyString() {
30 $this->assertTrue(utf8_is_word_chars(''));
33 function testAllWordChars() {
34 $this->assertTrue(utf8_is_word_chars('HelloWorld'));
37 function testSpecials() {
39 chr(0xe0 | (0x2234 >> 12)) .
40 chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
41 chr(0x80 | (0x2234 & 0x003f)) .
43 $this->assertFalse(utf8_is_word_chars($str));
48 //--------------------------------------------------------------------
53 class test_utf8_strip_specials extends UnitTestCase {
55 function test_utf8_strip_specials() {
56 $this->UnitTestCase('test_utf8_strip_specials()');
59 function testEmptyString() {
60 $this->assertEqual(utf8_strip_specials(''),'');
63 function testStrip() {
65 chr(0xe0 | (0x2234 >> 12)) .
66 chr(0x80 | ((0x2234 >> 6) & 0x003f)) .
67 chr(0x80 | (0x2234 & 0x003f)) .
69 $this->assertEqual(utf8_strip_specials($str),'HelloWorld');
74 //--------------------------------------------------------------------
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);