@@ -74,8 +74,9 @@ pub fn camel_case_start(s: &str) -> StrIndex {
74
74
/// Returns `StrIndex` of the last camel-case component of `s[idx..]`.
75
75
///
76
76
/// ```
77
- /// assert_eq!(camel_case_start("AbcDef", 0), StrIndex::new(0, 0));
78
- /// assert_eq!(camel_case_start("AbcDef", 1), StrIndex::new(3, 3));
77
+ /// # use clippy_utils::str_utils::{camel_case_start_from_idx, StrIndex};
78
+ /// assert_eq!(camel_case_start_from_idx("AbcDef", 0), StrIndex::new(0, 0));
79
+ /// assert_eq!(camel_case_start_from_idx("AbcDef", 1), StrIndex::new(3, 3));
79
80
/// ```
80
81
pub fn camel_case_start_from_idx ( s : & str , start_idx : usize ) -> StrIndex {
81
82
let char_count = s. chars ( ) . count ( ) ;
@@ -119,7 +120,10 @@ pub fn camel_case_start_from_idx(s: &str, start_idx: usize) -> StrIndex {
119
120
/// Get the indexes of camel case components of a string `s`
120
121
///
121
122
/// ```
122
- /// assert_eq!(camel_case_indexes("AbcDef"), vec![StrIndex::new(0, 0), StrIndex::new(3, 3)])
123
+ /// # use clippy_utils::str_utils::{camel_case_indexes, StrIndex};
124
+ /// assert_eq!(camel_case_indexes("AbcDef"), vec![StrIndex::new(0, 0), StrIndex::new(3, 3),
125
+ /// StrIndex::new(6, 6)]);
126
+ /// assert_eq!(camel_case_indexes("abcDef"), vec![StrIndex::new(3, 3), StrIndex::new(6, 6)]);
123
127
/// ```
124
128
pub fn camel_case_indexes ( s : & str ) -> Vec < StrIndex > {
125
129
let mut result = Vec :: new ( ) ;
@@ -138,6 +142,7 @@ pub fn camel_case_indexes(s: &str) -> Vec<StrIndex> {
138
142
/// Split camel case string into a vector of its components
139
143
///
140
144
/// ```
145
+ /// # use clippy_utils::str_utils::{camel_case_split, StrIndex};
141
146
/// assert_eq!(camel_case_split("AbcDef"), vec!["Abc", "Def"]);
142
147
/// ```
143
148
pub fn camel_case_split ( s : & str ) -> Vec < & str > {
@@ -288,17 +293,16 @@ mod test {
288
293
assert_eq ! ( camel_case_until( "ABCD" ) , StrIndex :: new( 0 , 0 ) ) ;
289
294
}
290
295
296
+ #[ test]
297
+ fn camel_case_start_from_idx_full ( ) {
298
+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 0 ) , StrIndex :: new( 0 , 0 ) ) ;
299
+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 1 ) , StrIndex :: new( 3 , 3 ) ) ;
300
+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 4 ) , StrIndex :: new( 6 , 6 ) ) ;
301
+ }
302
+
291
303
#[ test]
292
304
fn camel_case_indexes_full ( ) {
293
- assert_eq ! (
294
- camel_case_indexes( "AbcDef" ) ,
295
- vec![ StrIndex :: new( 0 , 0 ) , StrIndex :: new( 3 , 3 ) ]
296
- ) ;
297
- assert_eq ! (
298
- camel_case_indexes( "abcDef" ) ,
299
- vec![ StrIndex :: new( 0 , 0 ) , StrIndex :: new( 3 , 3 ) ]
300
- ) ;
301
- assert_eq ! ( camel_case_indexes( "Abc\u{f6} \u{f6} DD" ) , vec![ StrIndex :: new( 5 , 7 ) ] ) ;
305
+ assert_eq ! ( camel_case_indexes( "Abc\u{f6} \u{f6} DD" ) , vec![ StrIndex :: new( 7 , 9 ) ] ) ;
302
306
}
303
307
304
308
#[ test]
0 commit comments