Пример #1
0
def test_shrink_single_element_list():
    repeated = False
    l = [0]
    for x in qc_shrink(l):
        if x == l:
            repeated = True
    assert repeated == False, "Shrink must not repeat things already seen"
Пример #2
0
def test_shrink_floats(full_f):
    for f in qc_shrink(full_f):
        if abs(full_f) > 1:
            assert abs(f) <= abs(full_f)/2 + 1
        else:
            assert abs(f) >= abs(full_f)/2 + 1
        assert cmp(f,0) == cmp(full_f, 0)   # shrink shall not change sign
        assert isinstance(f, float)
Пример #3
0
def test_shrink_floats(full_f):
    for f in qc_shrink(full_f):
        assert isinstance(f, float), "floats must be shrunk to floats"
        assert abs(full_f) > 1 # TODO, check if something is appropriate for smaller number
        assert abs(f) <= abs(full_f)/2 + 1, "shrunk fload must be smaller than parent"
        assert cmp(f,0) == cmp(full_f, 0), "shrink must not change sign of floats"
Пример #4
0
def test_shrink_integers(full_i):
    for i in qc_shrink(full_i):
        assert isinstance(i, int), "ints must be shrunk to ints"
        assert abs(i) <= abs(full_i)/2 + 1, "ints must be shrunk to smaller ints"
        assert cmp(i,0) == cmp(full_i, 0),  "shrink must not change sign of ints"
Пример #5
0
def test_shrink_lists(full_l):
    for sub_l in qc_shrink(full_l):
        assert len(sub_l) <= len(full_l)/2 + 1, "list must be shrunk in half"
Пример #6
0
def test_shrink_empty_list():
    qc_shrink([]).next()    # there must be no next, an Exception must be raised
Пример #7
0
def shrink_bookcase(bookcase):
    if isinstance(bookcase, Bookcase):
        for shrinked_books in qc_shrink(bookcase.books):
            yield Bookcase(bookcase.num_shelves, shrinked_books)
Пример #8
0
def test_shrink_empty_list():
    empty_list_has_been_shrunk = False
    for x in qc_shrink([]):
        empty_list_has_been_shrunk = True
    assert empty_list_has_been_shrunk == False, "Empty lists must not be shrunk"
Пример #9
0
def test_shrink_integers(full_i):
    for i in qc_shrink(full_i):
        assert abs(i) <= abs(full_i)/2 + 1
        assert cmp(i,0) == cmp(full_i, 0)   # shrink shall not change sign
        assert isinstance(i, int)
Пример #10
0
def test_shrink_lists(full_l):
    for sub_l in qc_shrink(full_l):
        assert len(sub_l) <= len(full_l)/2 + 1