File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 21
21
#![ feature( rand) ]
22
22
#![ feature( step_by) ]
23
23
#![ feature( str_escape) ]
24
+ #![ feature( str_replacen) ]
24
25
#![ feature( test) ]
25
26
#![ feature( unboxed_closures) ]
26
27
#![ feature( unicode) ]
Original file line number Diff line number Diff line change @@ -218,6 +218,20 @@ fn test_is_empty() {
218
218
assert ! ( !"a" . is_empty( ) ) ;
219
219
}
220
220
221
+ #[ test]
222
+ fn test_replacen ( ) {
223
+ assert_eq ! ( "" . replacen( 'a' , "b" , 5 ) , "" ) ;
224
+ assert_eq ! ( "acaaa" . replacen( "a" , "b" , 3 ) , "bcbba" ) ;
225
+ assert_eq ! ( "aaaa" . replacen( "a" , "b" , 0 ) , "aaaa" ) ;
226
+
227
+ let test = "test" ;
228
+ assert_eq ! ( " test test " . replacen( test, "toast" , 3 ) , " toast toast " ) ;
229
+ assert_eq ! ( " test test " . replacen( test, "toast" , 0 ) , " test test " ) ;
230
+ assert_eq ! ( " test test " . replacen( test, "" , 5 ) , " " ) ;
231
+
232
+ assert_eq ! ( "qwer123zxc789" . replacen( char :: is_numeric, "" , 3 ) , "qwerzxc789" ) ;
233
+ }
234
+
221
235
#[ test]
222
236
fn test_replace ( ) {
223
237
let a = "a" ;
You can’t perform that action at this time.
0 commit comments