libcollections: fix fallout in unit tests
This commit is contained in:
parent
4d4915aa28
commit
646083510a
@ -903,21 +903,21 @@ mod tests {
|
||||
#[test]
|
||||
fn test_find() {
|
||||
assert_eq!("hello".find('l'), Some(2u));
|
||||
assert_eq!("hello".find(|c:char| c == 'o'), Some(4u));
|
||||
assert_eq!("hello".find(|&: c:char| c == 'o'), Some(4u));
|
||||
assert!("hello".find('x').is_none());
|
||||
assert!("hello".find(|c:char| c == 'x').is_none());
|
||||
assert!("hello".find(|&: c:char| c == 'x').is_none());
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u));
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u));
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".find(|&: c: char| c == '华'), Some(30u));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rfind() {
|
||||
assert_eq!("hello".rfind('l'), Some(3u));
|
||||
assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u));
|
||||
assert_eq!("hello".rfind(|&: c:char| c == 'o'), Some(4u));
|
||||
assert!("hello".rfind('x').is_none());
|
||||
assert!("hello".rfind(|c:char| c == 'x').is_none());
|
||||
assert!("hello".rfind(|&: c:char| c == 'x').is_none());
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u));
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u));
|
||||
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|&: c: char| c == '华'), Some(30u));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1281,7 +1281,7 @@ mod tests {
|
||||
assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11");
|
||||
let chars: &[char] = &['1', '2'];
|
||||
assert_eq!("12foo1bar12".trim_left_chars(chars), "foo1bar12");
|
||||
assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_numeric()), "foo1bar123");
|
||||
assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1296,7 +1296,7 @@ mod tests {
|
||||
assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar");
|
||||
let chars: &[char] = &['1', '2'];
|
||||
assert_eq!("12foo1bar12".trim_right_chars(chars), "12foo1bar");
|
||||
assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_numeric()), "123foo1bar");
|
||||
assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1311,7 +1311,7 @@ mod tests {
|
||||
assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar");
|
||||
let chars: &[char] = &['1', '2'];
|
||||
assert_eq!("12foo1bar12".trim_chars(chars), "foo1bar");
|
||||
assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_numeric()), "foo1bar");
|
||||
assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1787,14 +1787,14 @@ mod tests {
|
||||
let split: Vec<&str> = data.splitn(3, ' ').collect();
|
||||
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
|
||||
|
||||
let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
|
||||
let split: Vec<&str> = data.splitn(3, |&: c: char| c == ' ').collect();
|
||||
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
|
||||
|
||||
// Unicode
|
||||
let split: Vec<&str> = data.splitn(3, 'ä').collect();
|
||||
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
|
||||
|
||||
let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
|
||||
let split: Vec<&str> = data.splitn(3, |&: c: char| c == 'ä').collect();
|
||||
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
|
||||
}
|
||||
|
||||
@ -2588,7 +2588,7 @@ mod bench {
|
||||
let s = "Mary had a little lamb, Little lamb, little-lamb.";
|
||||
let len = s.split(' ').count();
|
||||
|
||||
b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
|
||||
b.iter(|| assert_eq!(s.split(|&: c: char| c == ' ').count(), len));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
|
Loading…
x
Reference in New Issue
Block a user