run rustfmt on libcollectionstest

This commit is contained in:
Srinivas Reddy Thatiparthy 2016-10-16 15:48:22 +05:30
parent 6dc035ed91
commit e820a866bc
No known key found for this signature in database
GPG key ID: 091C58F4BFC36571
8 changed files with 80 additions and 62 deletions

View file

@ -299,5 +299,7 @@ fn test_extend_specialization() {
#[allow(dead_code)] #[allow(dead_code)]
fn assert_covariance() { fn assert_covariance() {
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
d
}
} }

View file

@ -533,9 +533,7 @@ create_append_test!(test_append_1700, 1700);
fn rand_data(len: usize) -> Vec<(u32, u32)> { fn rand_data(len: usize) -> Vec<(u32, u32)> {
let mut rng = DeterministicRng::new(); let mut rng = DeterministicRng::new();
Vec::from_iter( Vec::from_iter((0..len).map(|_| (rng.next(), rng.next())))
(0..len).map(|_| (rng.next(), rng.next()))
)
} }
#[test] #[test]

View file

@ -25,7 +25,7 @@ impl DeterministicRng {
x: 0x193a6754, x: 0x193a6754,
y: 0xa8a7d469, y: 0xa8a7d469,
z: 0x97830e05, z: 0x97830e05,
w: 0x113ba7bb w: 0x113ba7bb,
} }
} }

View file

@ -39,17 +39,23 @@ fn test_hash() {
assert!(::hash(&x) == ::hash(&y)); assert!(::hash(&x) == ::hash(&y));
} }
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) where fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool, where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
{ {
let mut set_a = BTreeSet::new(); let mut set_a = BTreeSet::new();
let mut set_b = BTreeSet::new(); let mut set_b = BTreeSet::new();
for x in a { assert!(set_a.insert(*x)) } for x in a {
for y in b { assert!(set_b.insert(*y)) } assert!(set_a.insert(*x))
}
for y in b {
assert!(set_b.insert(*y))
}
let mut i = 0; let mut i = 0;
f(&set_a, &set_b, &mut |&x| { f(&set_a,
&set_b,
&mut |&x| {
assert_eq!(x, expected[i]); assert_eq!(x, expected[i]);
i += 1; i += 1;
true true
@ -82,9 +88,7 @@ fn test_difference() {
check_difference(&[], &[], &[]); check_difference(&[], &[], &[]);
check_difference(&[1, 12], &[], &[1, 12]); check_difference(&[1, 12], &[], &[1, 12]);
check_difference(&[], &[1, 2, 3, 9], &[]); check_difference(&[], &[1, 2, 3, 9], &[]);
check_difference(&[1, 3, 5, 9, 11], check_difference(&[1, 3, 5, 9, 11], &[3, 9], &[1, 5, 11]);
&[3, 9],
&[1, 5, 11]);
check_difference(&[-5, 11, 22, 33, 40, 42], check_difference(&[-5, 11, 22, 33, 40, 42],
&[-12, -5, 14, 23, 34, 38, 39, 50], &[-12, -5, 14, 23, 34, 38, 39, 50],
&[11, 22, 33, 40, 42]); &[11, 22, 33, 40, 42]);
@ -245,10 +249,18 @@ fn test_recovery() {
fn test_variance() { fn test_variance() {
use std::collections::btree_set::{IntoIter, Iter, Range}; use std::collections::btree_set::{IntoIter, Iter, Range};
fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> { v } fn set<'new>(v: BTreeSet<&'static str>) -> BTreeSet<&'new str> {
fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> { v } v
fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> { v } }
fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> { v } fn iter<'a, 'new>(v: Iter<'a, &'static str>) -> Iter<'a, &'new str> {
v
}
fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> {
v
}
fn range<'a, 'new>(v: Range<'a, &'static str>) -> Range<'a, &'new str> {
v
}
} }
#[test] #[test]
@ -277,9 +289,7 @@ fn test_append() {
fn rand_data(len: usize) -> Vec<u32> { fn rand_data(len: usize) -> Vec<u32> {
let mut rng = DeterministicRng::new(); let mut rng = DeterministicRng::new();
Vec::from_iter( Vec::from_iter((0..len).map(|_| rng.next()))
(0..len).map(|_| rng.next())
)
} }
#[test] #[test]

View file

@ -36,7 +36,9 @@ extern crate rustc_unicode;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
#[cfg(test)] #[macro_use] mod bench; #[cfg(test)]
#[macro_use]
mod bench;
mod binary_heap; mod binary_heap;
mod btree; mod btree;

View file

@ -599,8 +599,12 @@ fn test_cow_from() {
#[allow(dead_code)] #[allow(dead_code)]
fn assert_covariance() { fn assert_covariance() {
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> { i } d
}
fn into_iter<'new>(i: IntoIter<&'static str>) -> IntoIter<&'new str> {
i
}
} }
#[bench] #[bench]

View file

@ -1003,5 +1003,7 @@ fn test_contains() {
#[allow(dead_code)] #[allow(dead_code)]
fn assert_covariance() { fn assert_covariance() {
fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> { d } fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
d
}
} }