Skip to content

Commit 0b4d8d6

Browse files
committed
Added iterator tests
1 parent d6923dd commit 0b4d8d6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/libextra/bitv.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,25 @@ mod tests {
12651265
assert_eq!(from_bytes([0b00100110]).to_bools(), bools);
12661266
}
12671267
1268+
#[test]
1269+
fn test_bitv_iterator() {
1270+
let bools = [true, false, true, true];
1271+
let bitv = from_bools(bools);
1272+
1273+
for bitv.iter().zip(bools.iter()).advance |(act, &ex)| {
1274+
assert_eq!(ex, act);
1275+
}
1276+
}
1277+
1278+
#[test]
1279+
fn test_bitv_set_iterator() {
1280+
let bools = [true, false, true, true];
1281+
let bitv = BitvSet::from_bitv(from_bools(bools));
1282+
1283+
let idxs: ~[uint] = bitv.iter().collect();
1284+
assert_eq!(idxs, ~[0, 2, 3]);
1285+
}
1286+
12681287
#[test]
12691288
fn test_small_difference() {
12701289
let mut b1 = Bitv::new(3, false);

0 commit comments

Comments
 (0)