Пример #1
0
def test_longest_common_sequence():
    ODA = OneDimensionalArray
    expected_result = "5"

    str1 = [10, 22, 9, 33, 21, 50, 41, 60]
    output = longest_common_subsequence(str1)
    assert str(output) == expected_result

    expected_result = "7"

    I = [1, 2, 4, 6, 8, 12, 11, 9, 17]
    output = longest_common_subsequence(I)
    assert str(output) == expected_result

    X = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]
    output = longest_common_subsequence(X)
    assert str(output) == "6"

    Z = []
    output = longest_common_subsequence(Z)
    assert str(output) == "0"
Пример #2
0
def test_longest_common_sequence():
    ODA = OneDimensionalArray
    expected_result = "['A', 'S', 'C', 'I', 'I']"

    str1 = ODA(str, ['A', 'A', 'S', 'C', 'C', 'I', 'I'])
    str2 = ODA(str, ['A', 'S', 'S', 'C', 'I', 'I', 'I', 'I'])
    output = longest_common_subsequence(str1, str2)
    assert str(output) == expected_result

    expected_result = "['O', 'V', 'A']"

    I = ODA(str, ['O', 'V', 'A', 'L'])
    J = ODA(str, ['F', 'O', 'R', 'V', 'A', 'E', 'W'])
    output = longest_common_subsequence(I, J)
    assert str(output) == expected_result

    X = ODA(int, [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1])
    Y = ODA(int, [1, 2, 3, 4, 4, 3, 2, 1])
    output = longest_common_subsequence(X, Y)
    assert str(output) == '[1, 2, 3, 4, 4, 3, 2, 1]'

    Z = ODA(int, [])
    output = longest_common_subsequence(Y, Z)
    assert str(output) == '[]'