]> git.lizzy.rs Git - rust.git/blob - tests/matches.rs
Auto merge of #3645 - phansch:remove_copyright_headers, r=oli-obk
[rust.git] / tests / matches.rs
1 #![feature(rustc_private)]
2
3 extern crate syntax;
4 use std::collections::Bound;
5
6 #[test]
7 fn test_overlapping() {
8     use clippy_lints::matches::overlapping;
9     use syntax::source_map::DUMMY_SP;
10
11     let sp = |s, e| clippy_lints::matches::SpannedRange {
12         span: DUMMY_SP,
13         node: (s, e),
14     };
15
16     assert_eq!(None, overlapping::<u8>(&[]));
17     assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
18     assert_eq!(
19         None,
20         overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))])
21     );
22     assert_eq!(
23         None,
24         overlapping(&[
25             sp(1, Bound::Included(4)),
26             sp(5, Bound::Included(6)),
27             sp(10, Bound::Included(11))
28         ],)
29     );
30     assert_eq!(
31         Some((&sp(1, Bound::Included(4)), &sp(3, Bound::Included(6)))),
32         overlapping(&[sp(1, Bound::Included(4)), sp(3, Bound::Included(6))])
33     );
34     assert_eq!(
35         Some((&sp(5, Bound::Included(6)), &sp(6, Bound::Included(11)))),
36         overlapping(&[
37             sp(1, Bound::Included(4)),
38             sp(5, Bound::Included(6)),
39             sp(6, Bound::Included(11))
40         ],)
41     );
42 }