enable enum_set tests

This commit is contained in:
Jorge Aparicio 2015-03-11 19:28:58 -05:00
parent a079d5e4d2
commit e09bf82a31
2 changed files with 18 additions and 15 deletions

View File

@ -8,7 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::EnumSet;
use std::mem;
use collections::enum_set::{CLike, EnumSet};
use self::Foo::*;
#[derive(Copy, PartialEq, Debug)]
#[repr(usize)]
@ -144,23 +148,23 @@ fn test_contains() {
fn test_iterator() {
let mut e1: EnumSet<Foo> = EnumSet::new();
let elems: ::vec::Vec<Foo> = e1.iter().collect();
let elems: Vec<Foo> = e1.iter().collect();
assert!(elems.is_empty());
e1.insert(A);
let elems: ::vec::Vec<_> = e1.iter().collect();
let elems: Vec<_> = e1.iter().collect();
assert_eq!([A], elems);
e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
let elems: Vec<_> = e1.iter().collect();
assert_eq!([A,C], elems);
e1.insert(C);
let elems: ::vec::Vec<_> = e1.iter().collect();
let elems: Vec<_> = e1.iter().collect();
assert_eq!([A,C], elems);
e1.insert(B);
let elems: ::vec::Vec<_> = e1.iter().collect();
let elems: Vec<_> = e1.iter().collect();
assert_eq!([A,B,C], elems);
}
@ -178,35 +182,35 @@ fn test_operators() {
e2.insert(C);
let e_union = e1 | e2;
let elems: ::vec::Vec<_> = e_union.iter().collect();
let elems: Vec<_> = e_union.iter().collect();
assert_eq!([A,B,C], elems);
let e_intersection = e1 & e2;
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
let elems: Vec<_> = e_intersection.iter().collect();
assert_eq!([C], elems);
// Another way to express intersection
let e_intersection = e1 - (e1 - e2);
let elems: ::vec::Vec<_> = e_intersection.iter().collect();
let elems: Vec<_> = e_intersection.iter().collect();
assert_eq!([C], elems);
let e_subtract = e1 - e2;
let elems: ::vec::Vec<_> = e_subtract.iter().collect();
let elems: Vec<_> = e_subtract.iter().collect();
assert_eq!([A], elems);
// Bitwise XOR of two sets, aka symmetric difference
let e_symmetric_diff = e1 ^ e2;
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
let elems: Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!([A,B], elems);
// Another way to express symmetric difference
let e_symmetric_diff = (e1 - e2) | (e2 - e1);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
let elems: Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!([A,B], elems);
// Yet another way to express symmetric difference
let e_symmetric_diff = (e1 | e2) - (e1 & e2);
let elems: ::vec::Vec<_> = e_symmetric_diff.iter().collect();
let elems: Vec<_> = e_symmetric_diff.iter().collect();
assert_eq!([A,B], elems);
}

View File

@ -32,8 +32,7 @@ extern crate unicode;
mod binary_heap;
mod bit;
mod btree;
// FIXME(japaric) privacy
//mod enum_set;
mod enum_set;
mod fmt;
mod linked_list;
mod slice;