]> git.lizzy.rs Git - rust.git/blob - tests/matches.rs
Update `ui/for_loop` test output
[rust.git] / tests / matches.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 #![feature(rustc_private)]
12
13 extern crate clippy_lints;
14 extern crate syntax;
15 use std::collections::Bound;
16
17 #[test]
18 fn test_overlapping() {
19     use clippy_lints::matches::overlapping;
20     use crate::syntax::source_map::DUMMY_SP;
21
22     let sp = |s, e| clippy_lints::matches::SpannedRange {
23         span: DUMMY_SP,
24         node: (s, e),
25     };
26
27     assert_eq!(None, overlapping::<u8>(&[]));
28     assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
29     assert_eq!(
30         None,
31         overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))])
32     );
33     assert_eq!(
34         None,
35         overlapping(&[
36             sp(1, Bound::Included(4)),
37             sp(5, Bound::Included(6)),
38             sp(10, Bound::Included(11))
39         ],)
40     );
41     assert_eq!(
42         Some((&sp(1, Bound::Included(4)), &sp(3, Bound::Included(6)))),
43         overlapping(&[sp(1, Bound::Included(4)), sp(3, Bound::Included(6))])
44     );
45     assert_eq!(
46         Some((&sp(5, Bound::Included(6)), &sp(6, Bound::Included(11)))),
47         overlapping(&[
48             sp(1, Bound::Included(4)),
49             sp(5, Bound::Included(6)),
50             sp(6, Bound::Included(11))
51         ],)
52     );
53 }