File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 4545
4646 match range. start_bound ( ) {
4747 Bound :: Unbounded => Some ( end) ,
48- Bound :: Included ( i) => Some ( end - ( * i + 1 ) ) ,
49- Bound :: Excluded ( i) => Some ( end - * i ) ,
48+ Bound :: Included ( i) => Some ( end - * i ) ,
49+ Bound :: Excluded ( i) => Some ( end - ( * i + 1 ) ) ,
5050 }
5151 }
5252
@@ -1013,6 +1013,20 @@ mod tests {
10131013 use regex:: Regex ;
10141014 use unicode_categories:: UnicodeCategories ;
10151015
1016+ #[ test]
1017+ fn test_len_range_inclusive ( ) {
1018+ let range = Range :: Original ( 3 ..=7 ) ;
1019+ let len = range. len ( ) ;
1020+ assert_eq ! ( len, Some ( 5 ) ) ; // 7 - 3 + 1 = 5
1021+ }
1022+
1023+ #[ test]
1024+ fn test_len_range_exclusive ( ) {
1025+ let range = Range :: Original ( 3 ..7 ) ;
1026+ let len = range. len ( ) ;
1027+ assert_eq ! ( len, Some ( 4 ) ) ; // 7 - 3 = 4
1028+ }
1029+
10161030 #[ test]
10171031 fn nfd_adds_new_chars ( ) {
10181032 let mut n = NormalizedString :: from ( "élégant" ) ;
You can’t perform that action at this time.
0 commit comments