PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/utf8/tests/cases/utf8_ord.test.php

https://bitbucket.org/fieldsofview/scuttle-fork
PHP | 65 lines | 34 code | 10 blank | 21 comment | 1 complexity | 65f7394cf2ba993dce1d8d1f5a721e48 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id: utf8_ord.test.php,v 1.1 2006/03/26 22:26:16 harryf Exp $
  4. * @package utf8
  5. * @subpackage Tests
  6. */
  7. //--------------------------------------------------------------------
  8. /**
  9. * Includes
  10. * @package utf8
  11. * @subpackage Tests
  12. */
  13. require_once(dirname(__FILE__).'/../config.php');
  14. require_once UTF8 . '/ord.php';
  15. //--------------------------------------------------------------------
  16. /**
  17. * @package utf8
  18. * @subpackage Tests
  19. */
  20. class test_utf8_ord extends UnitTestCase {
  21. function test_utf8_ord() {
  22. $this->UnitTestCase('utf8_ord()');
  23. }
  24. function testEmptyStr() {
  25. $str = '';
  26. $this->assertEqual(utf8_ord($str),0);
  27. }
  28. function testAsciiChar() {
  29. $str = 'a';
  30. $this->assertEqual(utf8_ord($str),97);
  31. }
  32. function test2ByteChar() {
  33. $str = 'ñ';
  34. $this->assertEqual(utf8_ord($str),241);
  35. }
  36. function test3ByteChar() {
  37. $str = '₧';
  38. $this->assertEqual(utf8_ord($str),8359);
  39. }
  40. function test4ByteChar() {
  41. $str = "\xf0\x90\x8c\xbc";
  42. $this->assertEqual(utf8_ord($str),66364);
  43. }
  44. }
  45. //--------------------------------------------------------------------
  46. /**
  47. * @package utf8
  48. * @subpackage Tests
  49. */
  50. if (!defined('TEST_RUNNING')) {
  51. define('TEST_RUNNING', true);
  52. $test = &new test_utf8_ord();
  53. $reporter = & getTestReporter();
  54. $test->run($reporter);
  55. }