mirror of
https://github.com/predis/predis.git
synced 2026-08-30 04:02:22 +00:00
@@ -1,3 +1,10 @@
|
||||
v1.1.2 (2017-xx-xx)
|
||||
================================================================================
|
||||
|
||||
- __FIX__: pure CRC16 implementation failed to calculate the correct hash when
|
||||
the input value passed to the `hash()` method is an integer (PR #450).
|
||||
|
||||
|
||||
v1.1.1 (2016-06-16)
|
||||
================================================================================
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ class CRC16 implements HashGeneratorInterface
|
||||
// CRC-CCITT-16 algorithm
|
||||
$crc = 0;
|
||||
$CCITT_16 = self::$CCITT_16;
|
||||
|
||||
$value = (string) $value;
|
||||
$strlen = strlen($value);
|
||||
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
|
||||
@@ -36,4 +36,15 @@ class CRC16Test extends PredisTestCase
|
||||
$this->assertSame(25343, $crc16->hash('key:008'));
|
||||
$this->assertSame(29406, $crc16->hash('key:009'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testHashGenerationWithIntegerValues()
|
||||
{
|
||||
$crc16 = new CRC16();
|
||||
|
||||
$this->assertSame(13907, $crc16->hash(0));
|
||||
$this->assertSame(55177, $crc16->hash(1234));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user