Skip to content

Commit 701a3d5

Browse files
committed
---
yaml --- r: 48627 b: refs/heads/snap-stage3 c: d55225f h: refs/heads/master i: 48625: fd46555 48623: c8562ad v: v3
1 parent 6c0c302 commit 701a3d5

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ad16fecc332e5dd39236f43c491c009ea798352b
4+
refs/heads/snap-stage3: d55225f04a459c574d9533dcc4c06f953fa8fce5
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/treemap.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,25 +1141,30 @@ mod test_set {
11411141

11421142
#[test]
11431143
fn test_difference() {
1144-
let mut a = TreeSet::new();
1145-
let mut b = TreeSet::new();
1146-
1147-
fail_unless!(a.insert(1));
1148-
fail_unless!(a.insert(3));
1149-
fail_unless!(a.insert(5));
1150-
fail_unless!(a.insert(9));
1151-
fail_unless!(a.insert(11));
1144+
fn check_difference(a: &[int], b: &[int], expected: &[int]) {
1145+
let mut set_a = TreeSet::new();
1146+
let mut set_b = TreeSet::new();
11521147

1153-
fail_unless!(b.insert(3));
1154-
fail_unless!(b.insert(9));
1148+
for a.each |x| { fail_unless!(set_a.insert(*x)) }
1149+
for b.each |y| { fail_unless!(set_b.insert(*y)) }
11551150

1156-
let mut i = 0;
1157-
let expected = [1, 5, 11];
1158-
for a.difference(&b) |x| {
1159-
fail_unless!(*x == expected[i]);
1160-
i += 1
1151+
let mut i = 0;
1152+
for set_a.difference(&set_b) |x| {
1153+
fail_unless!(*x == expected[i]);
1154+
i += 1;
1155+
}
1156+
fail_unless!(i == expected.len());
11611157
}
1162-
fail_unless!(i == expected.len());
1158+
1159+
check_difference([], [], []);
1160+
check_difference([1, 12], [], [1, 12]);
1161+
check_difference([], [1, 2, 3, 9], []);
1162+
check_difference([1, 3, 5, 9, 11],
1163+
[3, 9],
1164+
[1, 5, 11]);
1165+
check_difference([-5, 11, 22, 33, 40, 42],
1166+
[-12, -5, 14, 23, 34, 38, 39, 50],
1167+
[11, 22, 33, 40, 42]);
11631168
}
11641169

11651170
#[test]

0 commit comments

Comments
 (0)