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 45
45
46
46
match range. start_bound ( ) {
47
47
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 ) ) ,
50
50
}
51
51
}
52
52
@@ -1013,6 +1013,20 @@ mod tests {
1013
1013
use regex:: Regex ;
1014
1014
use unicode_categories:: UnicodeCategories ;
1015
1015
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
+
1016
1030
#[ test]
1017
1031
fn nfd_adds_new_chars ( ) {
1018
1032
let mut n = NormalizedString :: from ( "élégant" ) ;
You can’t perform that action at this time.
0 commit comments