function UnicodeUnitTest::helperTestSubStr in SimpleTest 7
2 calls to UnicodeUnitTest::helperTestSubStr()
- UnicodeUnitTest::testEmulatedUnicode in tests/
unicode.test - Test emulated unicode features.
- UnicodeUnitTest::testMbStringUnicode in tests/
unicode.test - Test full unicode features implemented using the mbstring extension.
File
- tests/
unicode.test, line 126 - Various unicode handling tests.
Class
- UnicodeUnitTest
- Test unicode handling features implemented in unicode.inc.
Code
function helperTestSubStr() {
$testcase = array(
// 012345678901234567890123
array(
'frànçAIS is über-åwesome',
0,
1,
'f',
),
array(
'frànçAIS is über-åwesome',
0,
8,
'frànçAIS',
),
array(
'frànçAIS is über-åwesome',
0,
100,
'frànçAIS is über-åwesome',
),
array(
'frànçAIS is über-åwesome',
4,
4,
'çAIS',
),
array(
'frànçAIS is über-åwesome',
1,
0,
'',
),
array(
'frànçAIS is über-åwesome',
100,
0,
'',
),
array(
'frànçAIS is über-åwesome',
-4,
2,
'so',
),
array(
'frànçAIS is über-åwesome',
-7,
10,
'åwesome',
),
array(
'frànçAIS is über-åwesome',
5,
-10,
'AIS is üb',
),
);
foreach ($testcase as $test) {
list($input, $start, $length, $output) = $test;
$this
->assertEqual(drupal_substr($input, $start, $length), $output, t('%input substring-ed at offset %offset for %length characters is %output', array(
'%input' => $input,
'%offset' => $start,
'%length' => $length,
'%output' => $output,
)));
}
}