from govcrawler.utils.simhash_utils import content_simhash


def test_empty_returns_zeros():
    assert content_simhash("") == "0" * 16


def test_hex_16_chars():
    h = content_simhash("这是一段测试正文，用于生成 64-bit SimHash。")
    assert len(h) == 16
    assert all(c in "0123456789abcdef" for c in h)


def test_same_text_same_hash():
    t = "广州市人民政府关于发布无人驾驶航空器安全管控的公告"
    assert content_simhash(t) == content_simhash(t)


def test_different_text_usually_different_hash():
    a = content_simhash("完全不同的一段文字 A，讨论的是天气")
    b = content_simhash("完全不同的一段文字 B，讨论的是体育")
    assert a != b  # 2-gram SimHash, 不同主题极不可能碰撞
