def test_add():
    temp = SortedSet(range(100))
    temp._reset(7)
    temp.add(100)
    temp.add(90)
    temp._check()
    assert all(val == temp[val] for val in range(101))
Example #2
0
def test_add():
    temp = SortedSet(range(100))
    temp._reset(7)
    temp.add(100)
    temp.add(90)
    temp._check()
    assert all(val == temp[val] for val in range(101))
def test_discard():
    temp = SortedSet(range(100), load=7)
    temp.discard(0)
    temp.discard(99)
    temp.discard(50)
    temp.discard(1000)
    temp._check()
    assert len(temp) == 97
def test_count():
    temp = SortedSet(range(100), load=7)
    assert all(temp.count(val) == 1 for val in range(100))
    assert temp.count(100) == 0
    assert temp.count(0) == 1
    temp.add(0)
    assert temp.count(0) == 1
    temp._check()
def test_count():
    temp = SortedSet(range(100), load=7)
    assert all(temp.count(val) == 1 for val in range(100))
    assert temp.count(100) == 0
    assert temp.count(0) == 1
    temp.add(0)
    assert temp.count(0) == 1
    temp._check()
def test_discard():
    temp = SortedSet(range(100), load=7)
    temp.discard(0)
    temp.discard(99)
    temp.discard(50)
    temp.discard(1000)
    temp._check()
    assert len(temp) == 97
def test_stress(repeat=1000):
    sst = SortedSet(range(1000))

    for rpt in range(repeat):
        action = random.choice(actions)
        action(sst)

        try:
            sst._check()
        except AssertionError:
            print(action)
            raise

        start_len = len(sst)

        while len(sst) < 500:
            sst.add(random.randrange(0, 2000))

        while len(sst) > 2000:
            del sst[random.randrange(0, len(sst))]

        if start_len != len(sst):
            sst._check()
Example #8
0
def test_stress(repeat=1000):
    sst = SortedSet(range(1000))

    for rpt in range(repeat):
        action = random.choice(actions)
        action(sst)

        try:
            sst._check()
        except AssertionError:
            print(action)
            raise

        start_len = len(sst)

        while len(sst) < 500:
            sst.add(random.randrange(0, 2000))

        while len(sst) > 2000:
            del sst[random.randrange(0, len(sst))]

        if start_len != len(sst):
            sst._check()
def test_init():
    sst = SortedSet()
    sst._check()

    sst = SortedSet()
    sst._reset(10000)
    assert sst._list._load == 10000
    sst._check()

    sst = SortedSet(range(10000))
    assert all(tup[0] == tup[1] for tup in zip(sst, range(10000)))

    sst.clear()
    assert len(sst) == 0
    assert list(iter(sst)) == []
    sst._check()
Example #10
0
def test_init():
    sst = SortedSet()
    sst._check()

    sst = SortedSet()
    sst._reset(10000)
    assert sst._list._load == 10000
    sst._check()

    sst = SortedSet(range(10000))
    assert all(tup[0] == tup[1] for tup in zip(sst, range(10000)))

    sst.clear()
    assert len(sst) == 0
    assert list(iter(sst)) == []
    sst._check()
def test_init():
    temp = SortedSet(range(100), load=7)
    temp._check()
    assert all(val == temp[val] for val in temp)
def test_clear():
    temp = SortedSet(range(100), load=7)
    temp.clear()
    temp._check()
    assert len(temp) == 0
def test_init():
    temp = SortedSet(range(100))
    assert temp.key is None
    temp._reset(7)
    temp._check()
    assert all(val == temp[val] for val in temp)
Example #14
0
def test_clear():
    temp = SortedSet(range(100))
    temp._reset(7)
    temp.clear()
    temp._check()
    assert len(temp) == 0
Example #15
0
def test_init():
    temp = SortedSet(range(100))
    assert temp.key is None
    temp._reset(7)
    temp._check()
    assert all(val == temp[val] for val in temp)
def test_init():
    temp = SortedSet(range(100), load=7)
    temp._check()
    assert all(val == temp[val] for val in temp)