Source for file utf8_str_pad.test.php

Documentation is available at utf8_str_pad.test.php

  1. <?php
  2. /**
  3. @version $Id: utf8_str_pad.test.php,v 1.1 2007/09/09 20:39:50 pitlinz 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 '/str_pad.php';
  16.  
  17. //--------------------------------------------------------------------
  18. /**
  19. @author Oliver Saunders <oliver (a) osinternetservices.com>
  20. @package utf8
  21. @subpackage Tests
  22. */
  23. class test_utf8_str_pad extends UnitTestCase {
  24.     public function test(){
  25.         $toPad '<IñtërnëT>'// 10 characters
  26.         $padding 'ø__'// 4 characters
  27.         
  28.         $this->assertEqual(utf8_str_pad($toPad20)$toPad '          ');
  29.         $this->assertEqual(utf8_str_pad($toPad20' 'STR_PAD_LEFT)'          ' $toPad);
  30.         $this->assertEqual(utf8_str_pad($toPad20' 'STR_PAD_BOTH)'     ' $toPad '     ');
  31.         
  32.         $this->assertEqual(utf8_str_pad($toPad10)$toPad);
  33.         $this->assertEqual(str_pad('5char'4)'5char')// str_pos won't truncate input string
  34.         $this->assertEqual(utf8_str_pad($toPad8)$toPad);
  35.         
  36.         $this->assertEqual(utf8_str_pad($toPad20$paddingSTR_PAD_RIGHT)$toPad 'ø__ø__ø__ø');
  37.         $this->assertEqual(utf8_str_pad($toPad20$paddingSTR_PAD_LEFT)'ø__ø__ø__ø' $toPad);
  38.         $this->assertEqual(utf8_str_pad($toPad20$paddingSTR_PAD_BOTH)'ø__ø_' $toPad 'ø__ø_');
  39.     }
  40. }
  41.  
  42. //--------------------------------------------------------------------
  43. /**
  44. @package utf8
  45. @subpackage Tests
  46. */
  47. if (!defined('TEST_RUNNING')) {
  48.     define('TEST_RUNNING'true);
  49.     $test &new test_utf8_str_pad ();
  50.     $reporter getTestReporter();
  51.     $test->run($reporter);
  52. }

Documentation generated on Thu, 08 Jan 2009 17:49:19 +0100 by phpDocumentor 1.4.0a2