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