Esempio n. 1
0
def test_deque():
    """Deque fixtures."""
    from src.deque import Deque
    empty = Deque()
    one = Deque(3)
    multi = Deque([1, 2, 3, 4, 5])
    return empty, one, multi
def test():
    d = Deque()
    assert d.is_empty() is True

    d.add_rear(4)
    assert d.items == [4]

    d.add_rear("dog")
    assert d.items == ["dog", 4]

    d.add_front("cat")
    assert d.items == ["dog", 4, "cat"]

    d.add_front(True)
    assert d.items == ["dog", 4, "cat", True]

    assert d.size() == 4

    assert d.is_empty() is False

    d.add_rear(8.4)
    assert d.items == [8.4, "dog", 4, "cat", True]

    assert d.remove_rear() == 8.4

    assert d.remove_front() is True
Esempio n. 3
0
def test_deque_peekleft():
    from src.deque import Deque
    test_deque = Deque([
        1,
        2,
        3,
        4,
        5,
    ])
    assert test_deque.peekleft() == 5
Esempio n. 4
0
def test_deque_pop_1():
    from src.deque import Deque
    test_deque = Deque([
        1,
        2,
        3,
        4,
        5,
    ])
    assert test_deque.pop() == 1
    def is_palindrome(sentence):
        dq = Deque()
        sentence = ''.join(filter(str.isalnum, sentence.lower()))
        for char in sentence:
            dq.addFront(char)

        while dq.size() > 1:
            if dq.removeFront() != dq.removeTail():
                return False
        return True
Esempio n. 6
0
def test_deque_appendleft():
    from src.deque import Deque
    test_deque = Deque([
        1,
        2,
        3,
        4,
        5,
    ])
    test_deque.appendleft('bob')
    assert test_deque.peekleft() == 'bob'
Esempio n. 7
0
 def setUp(self):
     self.dq = Deque()
Esempio n. 8
0
def the_deque():
    """Queue fixture."""
    from src.deque import Deque
    the_deque = Deque()
    return the_deque
Esempio n. 9
0
def test_deque_popleft_2():
    from src.deque import Deque
    test_deque = Deque()
    with pytest.raises(AttributeError):
        test_deque.popleft()
Esempio n. 10
0
def test_deque_size(a):
    from src.deque import Deque
    test_deque = Deque(a)
    assert test_deque.size() == len(a)
Esempio n. 11
0
from src.deque import Deque
from ting_file_management.file_process import process, remove, file_metadata
from ting_word_searches.word_search import search_by_word, exist_word

ting = Deque()

process(ting, "./statics/arquivo_teste.txt")
process(ting, "./statics/teste2")
process(ting, "./statics/teste2.txt")
process(ting, "./statics/testando_3.txt")
remove(ting)
file_metadata(ting, 0)
search_by_word(ting, "lado")
exist_word(ting, "comprometimento")