3 * @version $Id: utf8_str_pad.test.php,v 1.1 2006/09/03 09:25:13 harryf Exp $
8 //--------------------------------------------------------------------
14 require_once(dirname(__FILE__).'/../config.php');
15 require_once UTF8 . '/str_pad.php';
17 //--------------------------------------------------------------------
19 * @author Oliver Saunders <oliver (a) osinternetservices.com>
23 class test_utf8_str_pad extends UnitTestCase {
24 public function test(){
25 $toPad = '<IñtërnëT>'; // 10 characters
26 $padding = 'ø__'; // 4 characters
28 $this->assertEqual(utf8_str_pad($toPad, 20), $toPad . ' ');
29 $this->assertEqual(utf8_str_pad($toPad, 20, ' ', STR_PAD_LEFT), ' ' . $toPad);
30 $this->assertEqual(utf8_str_pad($toPad, 20, ' ', STR_PAD_BOTH), ' ' . $toPad . ' ');
32 $this->assertEqual(utf8_str_pad($toPad, 10), $toPad);
33 $this->assertEqual(str_pad('5char', 4), '5char'); // str_pos won't truncate input string
34 $this->assertEqual(utf8_str_pad($toPad, 8), $toPad);
36 $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_RIGHT), $toPad . 'ø__ø__ø__ø');
37 $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_LEFT), 'ø__ø__ø__ø' . $toPad);
38 $this->assertEqual(utf8_str_pad($toPad, 20, $padding, STR_PAD_BOTH), 'ø__ø_' . $toPad . 'ø__ø_');
42 //--------------------------------------------------------------------
47 if (!defined('TEST_RUNNING')) {
48 define('TEST_RUNNING', true);
49 $test = &new test_utf8_str_pad ();
50 $reporter = & getTestReporter();
51 $test->run($reporter);