Skip to content

Commit 3ced5b0

Browse files
committed
add dlist.rs should_fail tests
1 parent 510af4d commit 3ced5b0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/libcore/dlist.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,54 @@ mod tests {
590590
l.assert_consistent(); assert l.pop().get() == 3;
591591
l.assert_consistent(); assert l.is_empty();
592592
}
593+
#[test] #[should_fail]
594+
fn test_asymmetric_link() {
595+
let l = create::<int>();
596+
let one = l.push_n(1);
597+
let two = l.push_n(2);
598+
two.prev = none;
599+
l.assert_consistent();
600+
}
601+
#[test] #[should_fail]
602+
fn test_cyclic_list() {
603+
let l = create::<int>();
604+
let one = l.push_n(1);
605+
let _two = l.push_n(2);
606+
let three = l.push_n(3);
607+
three.next = some(one);
608+
one.prev = some(three);
609+
l.assert_consistent();
610+
}
611+
#[test] #[should_fail]
612+
fn test_headless() {
613+
create::<int>().head();
614+
}
615+
#[test] #[should_fail]
616+
fn test_insert_already_present_before() {
617+
let l = create::<int>();
618+
let one = l.push_n(1);
619+
let two = l.push_n(2);
620+
l.insert_n_before(two, one);
621+
}
622+
#[test] #[should_fail]
623+
fn test_insert_already_present_after() {
624+
let l = create::<int>();
625+
let one = l.push_n(1);
626+
let two = l.push_n(2);
627+
l.insert_n_after(one, two);
628+
}
629+
#[test] #[should_fail]
630+
fn test_insert_before_orphan() {
631+
let l = create::<int>();
632+
let one = create_node(1);
633+
let two = create_node(2);
634+
l.insert_n_before(one, two);
635+
}
636+
#[test] #[should_fail]
637+
fn test_insert_after_orphan() {
638+
let l = create::<int>();
639+
let one = create_node(1);
640+
let two = create_node(2);
641+
l.insert_n_after(two, one);
642+
}
593643
}

0 commit comments

Comments
 (0)