1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-02 01:22:37 +02:00

Added isHexadecimal

This commit is contained in:
Lucas
2013-08-22 15:40:43 +02:00
parent f1abc38c17
commit a1d9787309
5 changed files with 65 additions and 0 deletions

View File

@@ -798,6 +798,27 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
return $testData;
}
public function stringsForIsHexadecimal()
{
$testData = array(
array(true, ''),
array(true, 'abcdef'),
array(true, 'ABCDEF'),
array(true, '0123456789'),
array(true, '0123456789AbCdEf'),
array(false, '0123456789x'),
array(false, 'ABCDEFx'),
array(true, 'abcdef', 'UTF-8'),
array(true, 'ABCDEF', 'UTF-8'),
array(true, '0123456789', 'UTF-8'),
array(true, '0123456789AbCdEf', 'UTF-8'),
array(false, '0123456789x', 'UTF-8'),
array(false, 'ABCDEFx', 'UTF-8'),
);
return $testData;
}
public function stringsForCount()
{
$testData = array(

View File

@@ -482,6 +482,16 @@ class StaticStringyTestCase extends CommonTest
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForIsHexadecimal
*/
public function testIsHexadecimal($expected, $str, $encoding = null)
{
$result = S::isHexadecimal($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForCount
*/

View File

@@ -562,6 +562,18 @@ class StringyTestCase extends CommonTest
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForIsHexadecimal
*/
public function testIsHexadecimal($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isHexadecimal();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForCount
*/