Fixed a String::tokenize bug for a single enclosed item, closes #4627

Added basic test coverage for String::tokenize

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6827 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
the_undefined 2008-05-13 02:05:07 +00:00
parent fca356c040
commit 6f64efb342
2 changed files with 19 additions and 2 deletions

View file

@ -157,8 +157,7 @@ class String extends Object {
}
if ($data{$tmpOffset} == $leftBound) {
$depth++;
}
if ($data{$tmpOffset} == $rightBound) {
} elseif ($data{$tmpOffset} == $rightBound) {
$depth--;
}
$offset = ++$tmpOffset;

View file

@ -116,5 +116,23 @@ class StringTest extends UnitTestCase {
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
$this->assertEqual($result, $expected);
}
function testTokenize() {
$result = String::tokenize('A,(short,boring test)');
$expected = array('A', '(short,boring test)');
$this->assertEqual($result, $expected);
$result = String::tokenize('A,(short,more interesting( test)');
$expected = array('A', '(short,more interesting( test)');
$this->assertEqual($result, $expected);
$result = String::tokenize('A,(short,very interesting( test))');
$expected = array('A', '(short,very interesting( test))');
$this->assertEqual($result, $expected);
$result = String::tokenize('"single tag"', ' ', '"', '"');
$expected = array('"single tag"');
$this->assertEqual($expected, $result);
}
}
?>