X-Git-Url: https://projects.mako.cc/source/scuttle/blobdiff_plain/bce919af7b49bbd06223f79b8c37a53a3d263ff0..c7f63c8b9b12efd7b3c10b9f80cda06eaf32068f:/includes/utf8/tests/cases/utf8_specials.test.php diff --git a/includes/utf8/tests/cases/utf8_specials.test.php b/includes/utf8/tests/cases/utf8_specials.test.php new file mode 100644 index 0000000..326e6ab --- /dev/null +++ b/includes/utf8/tests/cases/utf8_specials.test.php @@ -0,0 +1,86 @@ +UnitTestCase('test_utf8_is_word_chars()'); + } + + function testEmptyString() { + $this->assertTrue(utf8_is_word_chars('')); + } + + function testAllWordChars() { + $this->assertTrue(utf8_is_word_chars('HelloWorld')); + } + + function testSpecials() { + $str = 'Hello ' . + chr(0xe0 | (0x2234 >> 12)) . + chr(0x80 | ((0x2234 >> 6) & 0x003f)) . + chr(0x80 | (0x2234 & 0x003f)) . + ' World'; + $this->assertFalse(utf8_is_word_chars($str)); + } + +} + +//-------------------------------------------------------------------- +/** +* @package utf8 +* @subpackage Tests +*/ +class test_utf8_strip_specials extends UnitTestCase { + + function test_utf8_strip_specials() { + $this->UnitTestCase('test_utf8_strip_specials()'); + } + + function testEmptyString() { + $this->assertEqual(utf8_strip_specials(''),''); + } + + function testStrip() { + $str = 'Hello ' . + chr(0xe0 | (0x2234 >> 12)) . + chr(0x80 | ((0x2234 >> 6) & 0x003f)) . + chr(0x80 | (0x2234 & 0x003f)) . + ' World'; + $this->assertEqual(utf8_strip_specials($str),'HelloWorld'); + } + +} + +//-------------------------------------------------------------------- +/** +* @package utf8 +* @subpackage Tests +*/ +if (!defined('TEST_RUNNING')) { + define('TEST_RUNNING', true); + $test = &new GroupTest('utf8_ascii'); + $test->addTestCase(new test_utf8_strip_specials()); + $test->addTestCase(new test_utf8_is_word_chars()); + $reporter = & getTestReporter(); + $test->run($reporter); +}