示例#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
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"
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"
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"
def test_swap_on_empty():
    empty = MyList()
    empty.swap(1, 2)
    assert get_MyList(empty) == ""
def test_push_back_empty():
    test_pb = MyList()
    for ch in "abc":
        test_pb.push_back(ch)
    assert get_MyList(test_pb) == "abc"
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
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"
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"
def test_default_constructor():
    def_constructor = get_MyList(MyList())
    assert len(def_constructor) == 0
def test_insert_at_pos_valid():
    my_list = MyList("testing")
    my_list.insert_at_pos(2,'a')
    assert get_MyList(my_list) == "teasting"
def test_swap_both_valid():
    swap_me = MyList("swap")
    swap_me.swap(1,2)
    assert get_MyList(swap_me) == "sawp"
def test_reverse_empty():
    test_rev = MyList()
    test_rev.reverse()
    assert get_MyList(test_rev) == ""
def test_swap_both_invalid():
    swap_me = MyList("swap")
    swap_me.swap(-1,200)
    assert get_MyList(swap_me) == "swap"
def test_equals_operator_nonempty():
    test_string = MyList("test")
    test_string.reassign(MyList("newstring"))
    test_string = get_MyList(test_string)
    assert test_string == "newstring"
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) == ""
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"
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"
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"
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) == ""
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
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"
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) == ""
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"
def test_pop_back_nonempty():
    test_popb = MyList("popping")
    for _ in xrange(4):
        test_popb.pop_back()
    assert get_MyList(test_popb) == "pop"
def test_swap_invalid_j():
    swap_me = MyList("swap")
    swap_me.swap(1,10)
    assert get_MyList(swap_me) == "swap"
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"