Exemplo n.º 1
0
def test_copy_constructor_diff():
    copy_from = MyList("original")
    copy_to = MyList(copy_from)
    copy_to.push_front('a')
    copy_to = get_MyList(copy_to)
    copy_from = get_MyList(copy_from)
    assert len(copy_from) == 8 and len(copy_to) == 9
Exemplo n.º 2
0
def test_copy_constructor_diff():
    copy_from = MyList("original")
    copy_to = MyList(copy_from)
    copy_to.push_front('a')
    copy_to = get_MyList(copy_to)
    copy_from = get_MyList(copy_from)
    assert len(copy_from) == 8 and len(copy_to) == 9
Exemplo n.º 3
0
def test_addition_operator_mem_check():
    test_str = MyList("abc")
    test_str2 = MyList("def")
    test_str3 = test_str + test_str2
    test_str2.pop_back()

    assert get_MyList(test_str3) == "abcdef"
Exemplo n.º 4
0
def test_addition_operator_mem_check():
    test_str  = MyList("abc")
    test_str2 = MyList("def")
    test_str3 = test_str + test_str2
    test_str2.pop_back()

    assert get_MyList(test_str3) == "abcdef"
Exemplo n.º 5
0
def test_addition_operator_a_nonempty_b_empty():
    test_str  = MyList("123")
    test_str2 = MyList()
    test_str3 = test_str + test_str2
    assert get_MyList(test_str3) == "123"
Exemplo n.º 6
0
def test_insert_at_pos_valid():
    my_list = MyList("testing")
    my_list.insert_at_pos(2, 'a')
    assert get_MyList(my_list) == "teasting"
Exemplo n.º 7
0
def test_swap_invalid_j():
    swap_me = MyList("swap")
    swap_me.swap(1, 10)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 8
0
def test_swap_invalid_i():
    swap_me = MyList("swap")
    swap_me.swap(8, 2)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 9
0
def test_swap_on_empty():
    empty = MyList()
    empty.swap(1, 2)
    assert get_MyList(empty) == ""
Exemplo n.º 10
0
def test_push_back_empty():
    test_pb = MyList()
    for ch in "abc":
        test_pb.push_back(ch)
    assert get_MyList(test_pb) == "abc"
Exemplo n.º 11
0
def test_pop_back_empty():
    test_popb = MyList()
    test_popb.pop_back()
    assert get_MyList(test_popb) == ""
Exemplo n.º 12
0
def test_equals_operator_nonempty_mem_check():
    test_string = MyList("test")
    test_str2 = MyList("newstring")
    test_string.reassign(test_str2)
    test_str2.pop_back()
    assert get_MyList(test_string) != get_MyList(test_str2)
Exemplo n.º 13
0
def test_swap_both_invalid():
    swap_me = MyList("swap")
    swap_me.swap(-1, 200)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 14
0
def test_size():
    test_list = get_MyList(MyList("abcdefghij"))
    assert len(test_list) == 10
Exemplo n.º 15
0
def test_equals_operator_nonempty():
    test_string = MyList("test")
    test_string.reassign(MyList("newstring"))
    test_string = get_MyList(test_string)
    assert test_string == "newstring"
Exemplo n.º 16
0
def test_reverse_empty():
    test_rev = MyList()
    test_rev.reverse()
    assert get_MyList(test_rev) == ""
Exemplo n.º 17
0
def test_reverse_nonempty():
    test_rev = MyList("reverse")
    test_rev.reverse()
    assert get_MyList(test_rev) == "esrever"
Exemplo n.º 18
0
def test_copy_constructor_len():
    copy_from = MyList("original")
    copy_to = get_MyList(MyList(copy_from))
    copy_from = get_MyList(copy_from)
    assert len(copy_from) == 8 and len(copy_to) == 8
Exemplo n.º 19
0
def test_string_constructor():
    str_constructor = MyList("Iamastring")
    assert get_MyList(str_constructor) == "Iamastring"
Exemplo n.º 20
0
def test_addition_operator_a_nonempty_b_nonempty():
    test_str = MyList("abc")
    test_str2 = MyList("def")
    test_str3 = test_str + test_str2
    assert get_MyList(test_str3) == "abcdef"
Exemplo n.º 21
0
def test_push_front_empty():
    test_pf = MyList()
    for ch in "olleh":
        test_pf.push_front(ch)
    assert get_MyList(test_pf) == "hello"
Exemplo n.º 22
0
def test_addition_operator_a_nonempty_b_empty():
    test_str = MyList("123")
    test_str2 = MyList()
    test_str3 = test_str + test_str2
    assert get_MyList(test_str3) == "123"
Exemplo n.º 23
0
def test_default_constructor():
    def_constructor = get_MyList(MyList())
    assert len(def_constructor) == 0
Exemplo n.º 24
0
def test_insert_at_pos_valid():
    my_list = MyList("testing")
    my_list.insert_at_pos(2,'a')
    assert get_MyList(my_list) == "teasting"
Exemplo n.º 25
0
def test_swap_both_valid():
    swap_me = MyList("swap")
    swap_me.swap(1,2)
    assert get_MyList(swap_me) == "sawp"
Exemplo n.º 26
0
def test_reverse_empty():
    test_rev = MyList()
    test_rev.reverse()
    assert get_MyList(test_rev) == ""
Exemplo n.º 27
0
def test_swap_both_invalid():
    swap_me = MyList("swap")
    swap_me.swap(-1,200)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 28
0
def test_equals_operator_nonempty():
    test_string = MyList("test")
    test_string.reassign(MyList("newstring"))
    test_string = get_MyList(test_string)
    assert test_string == "newstring"
Exemplo n.º 29
0
def test_copy_constructor_len():
    copy_from = MyList("original")
    copy_to = get_MyList(MyList(copy_from))
    copy_from = get_MyList(copy_from)
    assert len(copy_from) == 8 and len(copy_to) == 8
Exemplo n.º 30
0
def test_swap_on_empty():
    empty = MyList()
    empty.swap(1, 2)
    assert get_MyList(empty) == ""
Exemplo n.º 31
0
def test_reverse_nonempty():
    test_rev = MyList("reverse")
    test_rev.reverse()
    assert get_MyList(test_rev) == "esrever"
Exemplo n.º 32
0
def test_string_constructor():
    str_constructor = MyList("Iamastring")
    assert get_MyList(str_constructor) == "Iamastring"
Exemplo n.º 33
0
def test_size():
    test_list = get_MyList(MyList("abcdefghij"))
    assert len(test_list) == 10
Exemplo n.º 34
0
def test_push_front_nonempty():
    test_pf = MyList("world")
    for ch in "olleh":
        test_pf.push_front(ch)
    assert get_MyList(test_pf) == "helloworld"
Exemplo n.º 35
0
def test_equals_operator_nonempty_mem_check():
    test_string = MyList("test")
    test_str2   = MyList("newstring")
    test_string.reassign(test_str2)
    test_str2.pop_back()
    assert get_MyList(test_string) != get_MyList(test_str2)
Exemplo n.º 36
0
def test_push_front_empty():
    test_pf = MyList()
    for ch in "olleh":
        test_pf.push_front(ch)
    assert get_MyList(test_pf) == "hello"
Exemplo n.º 37
0
def test_addition_operator_a_nonempty_b_nonempty():
    test_str  = MyList("abc")
    test_str2 = MyList("def")
    test_str3 = test_str + test_str2
    assert get_MyList(test_str3) == "abcdef"
Exemplo n.º 38
0
def test_push_back_nonempty():
    test_pb = MyList("hello")
    for ch in "world":
        test_pb.push_back(ch)
    assert get_MyList(test_pb) == "helloworld"
Exemplo n.º 39
0
def test_push_back_empty():
    test_pb = MyList()
    for ch in "abc":
        test_pb.push_back(ch)
    assert get_MyList(test_pb) == "abc"
Exemplo n.º 40
0
def test_pop_front_empty():
    test_popf = MyList()
    test_popf.pop_front()
    assert get_MyList(test_popf) == ""
Exemplo n.º 41
0
def test_push_front_nonempty():
    test_pf = MyList("world")
    for ch in "olleh":
        test_pf.push_front(ch)
    assert get_MyList(test_pf) == "helloworld"
Exemplo n.º 42
0
def test_default_constructor():
    def_constructor = get_MyList(MyList())
    assert len(def_constructor) == 0
Exemplo n.º 43
0
def test_push_back_nonempty():
    test_pb = MyList("hello")
    for ch in "world":
        test_pb.push_back(ch)
    assert get_MyList(test_pb) == "helloworld"
Exemplo n.º 44
0
def test_pop_front_nonempty():
    test_popf = MyList("popping")
    for _ in xrange(3):
        test_popf.pop_front()
    assert get_MyList(test_popf) == "ping"
Exemplo n.º 45
0
def test_pop_front_empty():
    test_popf = MyList()
    test_popf.pop_front()
    assert get_MyList(test_popf) == ""
Exemplo n.º 46
0
def test_pop_back_empty():
    test_popb = MyList()
    test_popb.pop_back()
    assert get_MyList(test_popb) == ""
Exemplo n.º 47
0
def test_pop_front_nonempty():
    test_popf = MyList("popping")
    for _ in xrange(3):
        test_popf.pop_front()
    assert get_MyList(test_popf) == "ping"
Exemplo n.º 48
0
def test_pop_back_nonempty():
    test_popb = MyList("popping")
    for _ in xrange(4):
        test_popb.pop_back()
    assert get_MyList(test_popb) == "pop"
Exemplo n.º 49
0
def test_pop_back_nonempty():
    test_popb = MyList("popping")
    for _ in xrange(4):
        test_popb.pop_back()
    assert get_MyList(test_popb) == "pop"
Exemplo n.º 50
0
def test_swap_invalid_j():
    swap_me = MyList("swap")
    swap_me.swap(1,10)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 51
0
def test_swap_invalid_i():
    swap_me = MyList("swap")
    swap_me.swap(8,2)
    assert get_MyList(swap_me) == "swap"
Exemplo n.º 52
0
def test_swap_both_valid():
    swap_me = MyList("swap")
    swap_me.swap(1, 2)
    assert get_MyList(swap_me) == "sawp"