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