コード例 #1
0
ファイル: test_inserts.py プロジェクト: blester125/prehashed
def test_insert(d):
    key = rand_string()
    value = rand_string()
    d[key] = value
    assert key in d
    assert super(PrehashedDict, d).__contains__(sha1_fn(key))
    assert d[key] == value
    assert super(PrehashedDict, d).__getitem__(sha1_fn(key))
コード例 #2
0
def find(needles, haystack, hash_me=True):
    found = True
    for k, v in needles:
        if hash_me:
            k = sha1_fn(k)
        found_me = False
        for h in haystack:
            if h[0] == k and h[1] == v:
                found_me = True
        found = found_me
    return found
コード例 #3
0
def test_sha1_obj_value(class_ex):
    gold = 633327772932199023258151861061014836005222876887
    assert sha1_fn(class_ex) == gold
コード例 #4
0
def test_sha1_obj_type(class_ex):
    assert isinstance(sha1_fn(class_ex), int)
コード例 #5
0
def test_sha1_int_value():
    key = 1
    gold = 304942582444936629325699363757435820077590259883
    assert sha1_fn(key) == gold
コード例 #6
0
def test_sha1_int_type():
    key = random.randint(2, 101)
    assert isinstance(sha1_fn(key), int)
コード例 #7
0
def test_sha1_value():
    key = 'test'
    gold = 966482230667555116936258103322711973649032657875
    assert sha1_fn(key) == gold
コード例 #8
0
def test_sha1_type():
    key = rand_string()
    assert isinstance(sha1_fn(key), int)