1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * @copyright Nichlas Severinsen
- * @license https://opensource.org/licenses/BSD-2-Clause
- */
- use Necklace\XxHash\XxHash32;
- use PHPUnit\Framework\TestCase;
- final class XxHash32Test extends TestCase
- {
- private $x;
- protected function setUp(): void
- {
- $this->x = new XxHash32;
- }
- protected function teardown(): void
- {
- unset($this->x);
- }
- public function testHash(): void
- {
- $this->assertEquals('3e2023cf', $this->x->hash('test'));
- }
- public function testHashWithSeed(): void
- {
- $this->assertEquals('f782311e', $this->x->hash('test', 1));
- $this->assertEquals('6e111138', $this->x->hash('test', 10));
- $this->assertEquals('9bc28b61', $this->x->hash('test', 100));
- }
- public function testReset(): void
- {
- $this->assertEquals(true, $this->x->reset());
- }
- public function testUpdateAndDigest(): void
- {
- $this->assertEquals(true, $this->x->update('te'));
- $this->assertEquals(true, $this->x->update('st'));
- $this->assertEquals('3e2023cf', $this->x->digest());
- }
- public function testResetWithSeed(): void
- {
- $this->assertEquals(true, $this->x->reset(1));
- $this->assertEquals(true, $this->x->update('te'));
- $this->assertEquals(true, $this->x->update('st'));
- $this->assertEquals('f782311e', $this->x->digest());
- $this->assertEquals(true, $this->x->reset(10));
- $this->assertEquals(true, $this->x->update('te'));
- $this->assertEquals(true, $this->x->update('st'));
- $this->assertEquals('6e111138', $this->x->digest());
- $this->assertEquals(true, $this->x->reset(100));
- $this->assertEquals(true, $this->x->update('te'));
- $this->assertEquals(true, $this->x->update('st'));
- $this->assertEquals('9bc28b61', $this->x->digest());
- }
- public function testHashFile(): void
- {
- $this->assertEquals('1dd21d01', $this->x->hashFile(__DIR__ . '/bootstrap.php'));
- }
- public function testHashFileWithSeed(): void
- {
- $this->assertEquals('0b3eb334', $this->x->hashFile(__DIR__ . '/bootstrap.php', 1));
- }
- }
|