2010-07-28 16:00:44 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
use std;
|
|
|
|
import std.deque;
|
|
|
|
|
2010-07-28 18:34:22 -05:00
|
|
|
fn test_simple() {
|
|
|
|
let deque.t[int] d = deque.create[int]();
|
|
|
|
check (d.size() == 0u);
|
|
|
|
d.add_front(17);
|
|
|
|
d.add_front(42);
|
|
|
|
d.add_back(137);
|
|
|
|
check (d.size() == 3u);
|
|
|
|
d.add_back(137);
|
|
|
|
check (d.size() == 4u);
|
|
|
|
|
|
|
|
log d.peek_front();
|
|
|
|
check (d.peek_front() == 42);
|
|
|
|
|
|
|
|
log d.peek_back();
|
|
|
|
check (d.peek_back() == 137);
|
|
|
|
|
|
|
|
let int i = d.pop_front();
|
|
|
|
log i;
|
|
|
|
check (i == 42);
|
|
|
|
|
|
|
|
i = d.pop_back();
|
|
|
|
log i;
|
|
|
|
check (i == 137);
|
|
|
|
|
|
|
|
i = d.pop_back();
|
|
|
|
log i;
|
|
|
|
check (i == 137);
|
|
|
|
|
|
|
|
i = d.pop_back();
|
|
|
|
log i;
|
|
|
|
check (i == 17);
|
|
|
|
|
|
|
|
/* FIXME (issue #138): Test d.get() once it no longer causes
|
|
|
|
* segfault. */
|
|
|
|
}
|
|
|
|
|
2010-07-28 16:00:44 -05:00
|
|
|
fn main() {
|
2010-07-28 18:34:22 -05:00
|
|
|
test_simple();
|
2010-07-28 16:00:44 -05:00
|
|
|
}
|