Ejemplo n.º 1
0
def test_docengine_comparator():
    """
    Comparator of pos for sorted list test
    """
    left_position = [0]
    left_authors = [-1]
    right_position = [0, 1]
    right_authors = [-1, 0]
    base_bits = CharPosition.BASE_BITS

    left_char_pos = CharPosition(left_position,
                                 left_authors,
                                 base_bits=base_bits)
    right_char_pos = CharPosition(right_position,
                                  right_authors,
                                  base_bits=base_bits)

    assert left_char_pos < right_char_pos
Ejemplo n.º 2
0
def test_docengine_allocator():
    """
    Test correctness of position allocation between two existing ones
    """
    left_position = [0]
    left_authors = [-1]
    right_position = [0, 1]
    right_authors = [-1, 0]
    base_bits = CharPosition.BASE_BITS

    test_allocator = Allocator(0)
    left_char_pos = CharPosition(left_position,
                                 left_authors,
                                 base_bits=base_bits)
    right_char_pos = CharPosition(right_position,
                                  right_authors,
                                  base_bits=base_bits)

    interval_at_depth = left_char_pos.interval_at(3)
    res_pos = test_allocator(left_char_pos, right_char_pos).position

    assert (0 < res_pos[-1] <= 5 or 123 <= res_pos[-1] < interval_at_depth)