Skip to content

Commit

Permalink
Add tests for BitAnd and BitXor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcrail committed Nov 7, 2014
1 parent 01b599e commit 12db4de
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libcollections/enum_set.rs
Expand Up @@ -403,9 +403,29 @@ mod test {
let elems = e_intersection.iter().collect();
assert_eq!(vec![C], elems)

// Another way to express intersection
let e_intersection = e1 - (e1 - e2);
let elems = e_intersection.iter().collect();
assert_eq!(vec![C], elems)

let e_subtract = e1 - e2;
let elems = e_subtract.iter().collect();
assert_eq!(vec![A], elems)

// Bitwise XOR of two sets, aka symmetric difference
let e_symmetric_diff = e1 ^ e2;
let elems = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)

// Another way to express symmetric difference
let e_symmetric_diff = (e1 - e2) | (e2 - e1);
let elems = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)

// Yet another way to express symmetric difference
let e_symmetric_diff = (e1 | e2) - (e1 & e2);
let elems = e_symmetric_diff.iter().collect();
assert_eq!(vec![A,B], elems)
}

#[test]
Expand Down

5 comments on commit 12db4de

@bors
Copy link
Contributor

@bors bors commented on 12db4de Nov 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at jbcrail@12db4de

@bors
Copy link
Contributor

@bors bors commented on 12db4de Nov 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jbcrail/rust/add-enum-set-bitxor = 12db4de into auto

@bors
Copy link
Contributor

@bors bors commented on 12db4de Nov 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jbcrail/rust/add-enum-set-bitxor = 12db4de merged ok, testing candidate = eeca3c7

@bors
Copy link
Contributor

@bors bors commented on 12db4de Nov 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 12db4de Nov 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = eeca3c7

Please sign in to comment.