2018-10-06 11:18:06 -05:00
|
|
|
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-12-23 10:48:30 -06:00
|
|
|
#![feature(rustc_private)]
|
|
|
|
|
|
|
|
extern crate syntax;
|
2017-01-30 05:30:16 -06:00
|
|
|
use std::collections::Bound;
|
2015-12-23 10:48:30 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_overlapping() {
|
2018-11-27 14:11:50 -06:00
|
|
|
use clippy_lints::matches::overlapping;
|
2018-12-29 09:04:45 -06:00
|
|
|
use syntax::source_map::DUMMY_SP;
|
2015-12-23 10:48:30 -06:00
|
|
|
|
2018-03-15 10:08:49 -05:00
|
|
|
let sp = |s, e| clippy_lints::matches::SpannedRange {
|
|
|
|
span: DUMMY_SP,
|
|
|
|
node: (s, e),
|
2016-06-05 18:42:39 -05:00
|
|
|
};
|
2015-12-23 10:48:30 -06:00
|
|
|
|
|
|
|
assert_eq!(None, overlapping::<u8>(&[]));
|
2017-01-30 05:30:16 -06:00
|
|
|
assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
|
2018-03-15 10:08:49 -05:00
|
|
|
assert_eq!(
|
|
|
|
None,
|
|
|
|
overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))])
|
|
|
|
);
|
2017-08-09 02:30:56 -05:00
|
|
|
assert_eq!(
|
|
|
|
None,
|
2017-09-05 04:33:04 -05:00
|
|
|
overlapping(&[
|
|
|
|
sp(1, Bound::Included(4)),
|
|
|
|
sp(5, Bound::Included(6)),
|
|
|
|
sp(10, Bound::Included(11))
|
|
|
|
],)
|
2017-08-09 02:30:56 -05:00
|
|
|
);
|
|
|
|
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)))),
|
2017-09-05 04:33:04 -05:00
|
|
|
overlapping(&[
|
|
|
|
sp(1, Bound::Included(4)),
|
|
|
|
sp(5, Bound::Included(6)),
|
|
|
|
sp(6, Bound::Included(11))
|
|
|
|
],)
|
2017-08-09 02:30:56 -05:00
|
|
|
);
|
2015-12-23 10:48:30 -06:00
|
|
|
}
|