@@ -1197,3 +1197,40 @@ where
11971197
11981198 None
11991199}
1200+
1201+ #[ test]
1202+ fn test_overlapping ( ) {
1203+ use rustc_span:: source_map:: DUMMY_SP ;
1204+
1205+ let sp = |s, e| SpannedRange {
1206+ span : DUMMY_SP ,
1207+ node : ( s, e) ,
1208+ } ;
1209+
1210+ assert_eq ! ( None , overlapping:: <u8 >( & [ ] ) ) ;
1211+ assert_eq ! ( None , overlapping( & [ sp( 1 , Bound :: Included ( 4 ) ) ] ) ) ;
1212+ assert_eq ! (
1213+ None ,
1214+ overlapping( & [ sp( 1 , Bound :: Included ( 4 ) ) , sp( 5 , Bound :: Included ( 6 ) ) ] )
1215+ ) ;
1216+ assert_eq ! (
1217+ None ,
1218+ overlapping( & [
1219+ sp( 1 , Bound :: Included ( 4 ) ) ,
1220+ sp( 5 , Bound :: Included ( 6 ) ) ,
1221+ sp( 10 , Bound :: Included ( 11 ) )
1222+ ] , )
1223+ ) ;
1224+ assert_eq ! (
1225+ Some ( ( & sp( 1 , Bound :: Included ( 4 ) ) , & sp( 3 , Bound :: Included ( 6 ) ) ) ) ,
1226+ overlapping( & [ sp( 1 , Bound :: Included ( 4 ) ) , sp( 3 , Bound :: Included ( 6 ) ) ] )
1227+ ) ;
1228+ assert_eq ! (
1229+ Some ( ( & sp( 5 , Bound :: Included ( 6 ) ) , & sp( 6 , Bound :: Included ( 11 ) ) ) ) ,
1230+ overlapping( & [
1231+ sp( 1 , Bound :: Included ( 4 ) ) ,
1232+ sp( 5 , Bound :: Included ( 6 ) ) ,
1233+ sp( 6 , Bound :: Included ( 11 ) )
1234+ ] , )
1235+ ) ;
1236+ }
0 commit comments