rust/tests/matches.rs

43 lines
1.1 KiB
Rust
Raw Normal View History

2015-12-23 17:48:30 +01:00
#![feature(rustc_private)]
extern crate syntax;
use std::collections::Bound;
2015-12-23 17:48:30 +01:00
#[test]
fn test_overlapping() {
2018-11-27 21:11:50 +01:00
use clippy_lints::matches::overlapping;
use syntax::source_map::DUMMY_SP;
2015-12-23 17:48:30 +01:00
let sp = |s, e| clippy_lints::matches::SpannedRange {
span: DUMMY_SP,
node: (s, e),
};
2015-12-23 17:48:30 +01:00
assert_eq!(None, overlapping::<u8>(&[]));
assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
assert_eq!(
None,
overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))])
);
2017-08-09 09:30:56 +02:00
assert_eq!(
None,
2017-09-05 11:33:04 +02:00
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(10, Bound::Included(11))
],)
2017-08-09 09:30:56 +02: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-09-05 11:33:04 +02:00
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(6, Bound::Included(11))
],)
2017-08-09 09:30:56 +02:00
);
2015-12-23 17:48:30 +01:00
}