rust-clippy/tests/matches.rs

25 lines
729 B
Rust
Raw Normal View History

2015-12-23 16:48:30 +00:00
#![feature(rustc_private)]
2016-08-17 16:35:25 +00:00
extern crate clippy_lints;
2015-12-23 16:48:30 +00:00
extern crate syntax;
#[test]
fn test_overlapping() {
2016-08-17 16:35:25 +00:00
use clippy_lints::matches::overlapping;
2015-12-23 16:48:30 +00:00
use syntax::codemap::DUMMY_SP;
let sp = |s, e| {
2016-08-17 16:35:25 +00:00
clippy_lints::matches::SpannedRange {
span: DUMMY_SP,
node: (s, e),
}
};
2015-12-23 16:48:30 +00:00
assert_eq!(None, overlapping::<u8>(&[]));
assert_eq!(None, overlapping(&[sp(1, 4)]));
assert_eq!(None, overlapping(&[sp(1, 4), sp(5, 6)]));
assert_eq!(None, overlapping(&[sp(1, 4), sp(5, 6), sp(10, 11)]));
assert_eq!(Some((&sp(1, 4), &sp(3, 6))), overlapping(&[sp(1, 4), sp(3, 6)]));
assert_eq!(Some((&sp(5, 6), &sp(6, 11))), overlapping(&[sp(1, 4), sp(5, 6), sp(6, 11)]));
}