Пример #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
Пример #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
Пример #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"
Пример #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"
Пример #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"
Пример #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"
Пример #7
0
def test_swap_invalid_j():
    swap_me = MyList("swap")
    swap_me.swap(1, 10)
    assert get_MyList(swap_me) == "swap"
Пример #8
0
def test_swap_invalid_i():
    swap_me = MyList("swap")
    swap_me.swap(8, 2)
    assert get_MyList(swap_me) == "swap"
Пример #9
0
def test_swap_on_empty():
    empty = MyList()
    empty.swap(1, 2)
    assert get_MyList(empty) == ""
Пример #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"
Пример #11
0
def test_pop_back_empty():
    test_popb = MyList()
    test_popb.pop_back()
    assert get_MyList(test_popb) == ""
Пример #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)
Пример #13
0
def test_swap_both_invalid():
    swap_me = MyList("swap")
    swap_me.swap(-1, 200)
    assert get_MyList(swap_me) == "swap"
Пример #14
0
def test_size():
    test_list = get_MyList(MyList("abcdefghij"))
    assert len(test_list) == 10
Пример #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"
Пример #16
0
def test_reverse_empty():
    test_rev = MyList()
    test_rev.reverse()
    assert get_MyList(test_rev) == ""
Пример #17
0
def test_reverse_nonempty():
    test_rev = MyList("reverse")
    test_rev.reverse()
    assert get_MyList(test_rev) == "esrever"
Пример #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
Пример #19
0
def test_string_constructor():
    str_constructor = MyList("Iamastring")
    assert get_MyList(str_constructor) == "Iamastring"
Пример #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"
Пример #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"
Пример #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"
Пример #23
0
def test_default_constructor():
    def_constructor = get_MyList(MyList())
    assert len(def_constructor) == 0
Пример #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"
Пример #25
0
def test_swap_both_valid():
    swap_me = MyList("swap")
    swap_me.swap(1,2)
    assert get_MyList(swap_me) == "sawp"
Пример #26
0
def test_reverse_empty():
    test_rev = MyList()
    test_rev.reverse()
    assert get_MyList(test_rev) == ""
Пример #27
0
def test_swap_both_invalid():
    swap_me = MyList("swap")
    swap_me.swap(-1,200)
    assert get_MyList(swap_me) == "swap"
Пример #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"
Пример #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
Пример #30
0
def test_swap_on_empty():
    empty = MyList()
    empty.swap(1, 2)
    assert get_MyList(empty) == ""
Пример #31
0
def test_reverse_nonempty():
    test_rev = MyList("reverse")
    test_rev.reverse()
    assert get_MyList(test_rev) == "esrever"
Пример #32
0
def test_string_constructor():
    str_constructor = MyList("Iamastring")
    assert get_MyList(str_constructor) == "Iamastring"
Пример #33
0
def test_size():
    test_list = get_MyList(MyList("abcdefghij"))
    assert len(test_list) == 10
Пример #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"
Пример #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)
Пример #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"
Пример #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"
Пример #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"
Пример #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"
Пример #40
0
def test_pop_front_empty():
    test_popf = MyList()
    test_popf.pop_front()
    assert get_MyList(test_popf) == ""
Пример #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"
Пример #42
0
def test_default_constructor():
    def_constructor = get_MyList(MyList())
    assert len(def_constructor) == 0
Пример #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"
Пример #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"
Пример #45
0
def test_pop_front_empty():
    test_popf = MyList()
    test_popf.pop_front()
    assert get_MyList(test_popf) == ""
Пример #46
0
def test_pop_back_empty():
    test_popb = MyList()
    test_popb.pop_back()
    assert get_MyList(test_popb) == ""
Пример #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"
Пример #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"
Пример #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"
Пример #50
0
def test_swap_invalid_j():
    swap_me = MyList("swap")
    swap_me.swap(1,10)
    assert get_MyList(swap_me) == "swap"
Пример #51
0
def test_swap_invalid_i():
    swap_me = MyList("swap")
    swap_me.swap(8,2)
    assert get_MyList(swap_me) == "swap"
Пример #52
0
def test_swap_both_valid():
    swap_me = MyList("swap")
    swap_me.swap(1, 2)
    assert get_MyList(swap_me) == "sawp"