Esempio n. 1
0
def test_jl_in():
    j = JudyL()
    assert 42 not in j
    j[42] = 1
    assert 42 in j
    assert 43 not in j
    j.clear()
Esempio n. 2
0
def test_jl_in():
    j = JudyL()
    assert 42 not in j
    j[42] = 1
    assert 42 in j
    assert 43 not in j
    j.clear()
Esempio n. 3
0
def test_jl_inc():
    with JudyL() as j:
        j[1] = 2
        j.inc(1)
        assert j[1] == 3
        j.inc(1, 10)
        assert j[1] == 13
Esempio n. 4
0
def test_jl_signed():
    with JudyL([(-1, -1)]) as j:
        assert -1 in j
        assert j[-1] == -1
        for k, v in j:
            assert k == -1
            assert v == -1
        for k, v in iteritems(j):
            assert k == -1
            assert v == -1
        for k in j.keys():
            assert k == -1
Esempio n. 5
0
def test_jl_keys():
    with JudyL() as j:
        for i in range(10):
            j[i + 10] = i
        i = 0
        start = True
        for k in j.keys():
            if start:
                assert k == 10
                start = False
            i += 1
        assert i == 10
Esempio n. 6
0
def test_jl_iteritems():
    with JudyL() as j:
        for i in range(10):
            j[i + 10] = i
        i = 0
        start = True
        for k, v in iteritems(j):
            assert k == v + 10
            if start:
                assert k == 10
                start = False
            i += 1
        assert i == 10
Esempio n. 7
0
def test_jl_bool():
    j = JudyL()
    assert not bool(j)
    j[42] = 1
    assert bool(j)
    j.clear()
Esempio n. 8
0
def test_jl_from_list():
    with JudyL([(10, 1), (2, 11)]) as j:
        d = dict(j)
        assert d == {2: 11, 10: 1}
Esempio n. 9
0
def test_jl_from_dict():
    with JudyL({10: 1, 2: 11}) as j:
        d = dict(j)
        assert d == {2: 11, 10: 1}
Esempio n. 10
0
def test_jl_get_absent():
    with JudyL() as j:
        x = j.get(12, 1)
        assert x == 1
Esempio n. 11
0
def test_jl_getitem_absent():
    with JudyL() as j:
        x = j[12]
Esempio n. 12
0
def test_jl_len():
    with JudyL() as j:
        for i in range(10):
            j[i + 10] = i
        assert len(j) == 10
Esempio n. 13
0
def test_jl_bool():
    j = JudyL()
    assert not bool(j)
    j[42] = 1
    assert bool(j)
    j.clear()