1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * @copyright Nichlas Severinsen
- * @license https://opensource.org/licenses/BSD-2-Clause
- */
- use Necklace\XxHash\XxHash64;
- use PHPUnit\Framework\TestCase;
- final class XxHash64Test extends TestCase
- {
- private $x;
- protected function setUp(): void
- {
- $this->x = new XxHash64;
- }
- protected function teardown(): void
- {
- unset($this->x);
- }
- public function testHash(): void
- {
- $this->assertEquals('4fdcca5ddb678139', $this->x->hash('test'));
- }
- public function testHashWithSeed(): void
- {
- $this->assertEquals('99ebbf9ba48f4c5d', $this->x->hash('test', 1));
- $this->assertEquals('52afb6bd010e4676', $this->x->hash('test', 10));
- $this->assertEquals('69f66fd0f32510c2', $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('4fdcca5ddb678139', $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('99ebbf9ba48f4c5d', $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('52afb6bd010e4676', $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('69f66fd0f32510c2', $this->x->digest());
- }
- public function testHashFile(): void
- {
- $this->assertEquals('cee0f97cde3a4cda', $this->x->hashFile(__DIR__ . '/bootstrap.php'));
- }
- public function testHashFileWithSeed(): void
- {
- $this->assertEquals('ce66936562b66421', $this->x->hashFile(__DIR__ . '/bootstrap.php', 1));
- }
- }
|