CRC16Test.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Cluster\Hash;
  11. use PredisTestCase;
  12. /**
  13. *
  14. */
  15. class CRC16Test extends PredisTestCase
  16. {
  17. /**
  18. * @group disconnected
  19. */
  20. public function testHashGeneration()
  21. {
  22. $crc16 = new CRC16();
  23. $this->assertSame(58359, $crc16->hash('key:000'));
  24. $this->assertSame(62422, $crc16->hash('key:001'));
  25. $this->assertSame(50101, $crc16->hash('key:002'));
  26. $this->assertSame(54164, $crc16->hash('key:003'));
  27. $this->assertSame(41843, $crc16->hash('key:004'));
  28. $this->assertSame(45906, $crc16->hash('key:005'));
  29. $this->assertSame(33585, $crc16->hash('key:006'));
  30. $this->assertSame(37648, $crc16->hash('key:007'));
  31. $this->assertSame(25343, $crc16->hash('key:008'));
  32. $this->assertSame(29406, $crc16->hash('key:009'));
  33. }
  34. /**
  35. * @group disconnected
  36. */
  37. public function testHashGenerationWithIntegerValues()
  38. {
  39. $crc16 = new CRC16();
  40. $this->assertSame(13907, $crc16->hash(0));
  41. $this->assertSame(55177, $crc16->hash(1234));
  42. }
  43. }