]> git.lizzy.rs Git - rust.git/blob - tests/matches.rs
Rust upgrade to rustc 1.22.0-nightly (14039a42a 2017-09-22)
[rust.git] / tests / matches.rs
1 #![feature(rustc_private)]
2
3 extern crate clippy_lints;
4 extern crate syntax;
5 use std::collections::Bound;
6
7 #[test]
8 fn test_overlapping() {
9     use clippy_lints::matches::overlapping;
10     use syntax::codemap::DUMMY_SP;
11
12     let sp = |s, e| {
13         clippy_lints::matches::SpannedRange {
14             span: DUMMY_SP,
15             node: (s, e),
16         }
17     };
18
19     assert_eq!(None, overlapping::<u8>(&[]));
20     assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
21     assert_eq!(None, overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))]));
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 }