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

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

https://bitbucket.org/fieldsofview/scuttle-fork
PHP | 81 lines | 49 code | 11 blank | 21 comment | 1 complexity | 88abee4cc86d1db6efddb0e2d6caf84c MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id: utf8_stristr.test.php,v 1.2 2006/02/25 14:52:18 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 . '/stristr.php';
  15. //--------------------------------------------------------------------
  16. /**
  17. * @package utf8
  18. * @subpackage Tests
  19. */
  20. class test_utf8_stristr extends UnitTestCase {
  21. function test_utf8_stristr () {
  22. $this->UnitTestCase('test_utf8_stristr()');
  23. }
  24. function testSubstr() {
  25. $str = 'iñtërnâtiônàlizætiøn';
  26. $search = 'NÂT';
  27. $this->assertEqual(utf8_stristr($str,$search),'nâtiônàlizætiøn');
  28. }
  29. function testSubstrNoMatch() {
  30. $str = 'iñtërnâtiônàlizætiøn';
  31. $search = 'foo';
  32. $this->assertFalse(utf8_stristr($str,$search));
  33. }
  34. function testEmptySearch() {
  35. $str = 'iñtërnâtiônàlizætiøn';
  36. $search = '';
  37. $this->assertEqual(utf8_stristr($str,$search),'iñtërnâtiônàlizætiøn');
  38. }
  39. function testEmptyStr() {
  40. $str = '';
  41. $search = 'NÂT';
  42. $this->assertFalse(utf8_stristr($str,$search));
  43. }
  44. function testEmptyBoth() {
  45. $str = '';
  46. $search = '';
  47. $this->assertEqual(utf8_stristr($str,$search),'');
  48. }
  49. function testLinefeedStr() {
  50. $str = "iñt\nërnâtiônàlizætiøn";
  51. $search = 'NÂT';
  52. $this->assertEqual(utf8_stristr($str,$search),'nâtiônàlizætiøn');
  53. }
  54. function testLinefeedBoth() {
  55. $str = "iñtërn\nâtiônàlizætiøn";
  56. $search = "N\nÂT";
  57. $this->assertEqual(utf8_stristr($str,$search),"n\nâtiônàlizætiøn");
  58. }
  59. }
  60. //--------------------------------------------------------------------
  61. /**
  62. * @package utf8
  63. * @subpackage Tests
  64. */
  65. if (!defined('TEST_RUNNING')) {
  66. define('TEST_RUNNING', true);
  67. $test = &new test_utf8_stristr ();
  68. $reporter = & getTestReporter();
  69. $test->run($reporter);
  70. }