Skip to content

Commit

Permalink
Xxhash test cleanup (#200)
Browse files Browse the repository at this point in the history
* clean up of the rounding functions

* fix: time span math

* fix: type annotations

* cleanup xxhash tests
  • Loading branch information
jessekrubin authored Feb 13, 2025
1 parent 60d7601 commit 85f0954
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 1,936 deletions.
46 changes: 46 additions & 0 deletions tests/xxhash/_xxhash_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from __future__ import annotations

from pathlib import Path
from typing import TypedDict

import ry

_PWD = Path(__file__).parent.absolute()
_TEST_DATA = _PWD / "xxhash.ndjson"

XX32_SEEDS = [0, 1, 2**32 - 1]
XX64_SEEDS = [0, 1, 2**64 - 1]
XX128_SEEDS = [0, 1, 2**64 - 1] # same as 64-bit seeds


class XXHashDataRecord(TypedDict):
buf: str
xxh32_0x00000000: str
xxh32_0x00000001: str
xxh32_0xFFFFFFFF: str
xxh64_0x00000000: str
xxh64_0x00000001: str
xxh64_0xFFFFFFFFFFFFFFFF: str
xxh3_64_0x00000000: str
xxh3_64_0x00000001: str
xxh3_64_0xFFFFFFFFFFFFFFFF: str
xxh3_128_0x00000000: str
xxh3_128_0x00000001: str
xxh3_128_0xFFFFFFFFFFFFFFFF: str


def _load_data():
with open(_TEST_DATA, "r") as f:
xx32_test_data = f.read()
lines = xx32_test_data.split("\n")
return [
XXHashDataRecord(
**row,
)
for row in (
ry.parse_json(line) for line in lines if line.strip() if line.strip()
)
]


XXHASH_TEST_DATA = _load_data()
Loading

0 comments on commit 85f0954

Please sign in to comment.