mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-09-02 01:22:37 +02:00
Added isHexadecimal
This commit is contained in:
@@ -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(
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user