Move matches test in matches module

This commit is contained in:
flip1995 2020-04-03 21:31:47 +02:00
parent 045722a17e
commit 30503a91d2
No known key found for this signature in database
GPG key ID: 2CEFCDB27ED0BE79
2 changed files with 37 additions and 42 deletions

View file

@ -1197,3 +1197,40 @@ where
None
}
#[test]
fn test_overlapping() {
use rustc_span::source_map::DUMMY_SP;
let sp = |s, e| SpannedRange {
span: DUMMY_SP,
node: (s, e),
};
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))])
);
assert_eq!(
None,
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(10, Bound::Included(11))
],)
);
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)))),
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(6, Bound::Included(11))
],)
);
}

View file

@ -1,42 +0,0 @@
#![feature(rustc_private)]
extern crate rustc_span;
use std::collections::Bound;
#[test]
fn test_overlapping() {
use clippy_lints::matches::overlapping;
use rustc_span::source_map::DUMMY_SP;
let sp = |s, e| clippy_lints::matches::SpannedRange {
span: DUMMY_SP,
node: (s, e),
};
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))])
);
assert_eq!(
None,
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(10, Bound::Included(11))
],)
);
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)))),
overlapping(&[
sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(6, Bound::Included(11))
],)
);
}