@@ -387,7 +387,7 @@ mod tests {
387
387
388
388
#[ test]
389
389
fn test_push_bytes ( ) {
390
- let mut s = String :: from_str ( "ABC" ) ;
390
+ let mut s = "ABC" . to_string ( ) ;
391
391
unsafe {
392
392
s. push_bytes ( [ 'D' as u8 ] ) ;
393
393
}
@@ -407,7 +407,7 @@ mod tests {
407
407
408
408
#[ test]
409
409
fn test_push_char ( ) {
410
- let mut data = String :: from_str ( "ประเทศไทย中" ) ;
410
+ let mut data = "ประเทศไทย中" . to_string ( ) ;
411
411
data. push_char ( '华' ) ;
412
412
data. push_char ( 'b' ) ; // 1 byte
413
413
data. push_char ( '¢' ) ; // 2 byte
@@ -418,7 +418,7 @@ mod tests {
418
418
419
419
#[ test]
420
420
fn test_pop_char ( ) {
421
- let mut data = String :: from_str ( "ประเทศไทย中华b¢€𤭢" ) ;
421
+ let mut data = "ประเทศไทย中华b¢€𤭢" . to_string ( ) ;
422
422
assert_eq ! ( data. pop_char( ) . unwrap( ) , '𤭢' ) ; // 4 bytes
423
423
assert_eq ! ( data. pop_char( ) . unwrap( ) , '€' ) ; // 3 bytes
424
424
assert_eq ! ( data. pop_char( ) . unwrap( ) , '¢' ) ; // 2 bytes
@@ -429,7 +429,7 @@ mod tests {
429
429
430
430
#[ test]
431
431
fn test_shift_char ( ) {
432
- let mut data = String :: from_str ( "𤭢€¢b华ประเทศไทย中" ) ;
432
+ let mut data = "𤭢€¢b华ประเทศไทย中" . to_string ( ) ;
433
433
assert_eq ! ( data. shift_char( ) . unwrap( ) , '𤭢' ) ; // 4 bytes
434
434
assert_eq ! ( data. shift_char( ) . unwrap( ) , '€' ) ; // 3 bytes
435
435
assert_eq ! ( data. shift_char( ) . unwrap( ) , '¢' ) ; // 2 bytes
@@ -440,15 +440,15 @@ mod tests {
440
440
441
441
#[ test]
442
442
fn test_str_truncate ( ) {
443
- let mut s = String :: from_str ( "12345" ) ;
443
+ let mut s = "12345" . to_string ( ) ;
444
444
s. truncate ( 5 ) ;
445
445
assert_eq ! ( s. as_slice( ) , "12345" ) ;
446
446
s. truncate ( 3 ) ;
447
447
assert_eq ! ( s. as_slice( ) , "123" ) ;
448
448
s. truncate ( 0 ) ;
449
449
assert_eq ! ( s. as_slice( ) , "" ) ;
450
450
451
- let mut s = String :: from_str ( "12345" ) ;
451
+ let mut s = "12345" . to_string ( ) ;
452
452
let p = s. as_slice ( ) . as_ptr ( ) ;
453
453
s. truncate ( 3 ) ;
454
454
s. push_str ( "6" ) ;
@@ -459,30 +459,30 @@ mod tests {
459
459
#[ test]
460
460
#[ should_fail]
461
461
fn test_str_truncate_invalid_len ( ) {
462
- let mut s = String :: from_str ( "12345" ) ;
462
+ let mut s = "12345" . to_string ( ) ;
463
463
s. truncate ( 6 ) ;
464
464
}
465
465
466
466
#[ test]
467
467
#[ should_fail]
468
468
fn test_str_truncate_split_codepoint ( ) {
469
- let mut s = String :: from_str ( "\u00FC " ) ; // ü
469
+ let mut s = "\u00FC " . to_string ( ) ; // ü
470
470
s. truncate ( 1 ) ;
471
471
}
472
472
473
473
#[ test]
474
474
fn test_str_clear ( ) {
475
- let mut s = String :: from_str ( "12345" ) ;
475
+ let mut s = "12345" . to_string ( ) ;
476
476
s. clear ( ) ;
477
477
assert_eq ! ( s. len( ) , 0 ) ;
478
478
assert_eq ! ( s. as_slice( ) , "" ) ;
479
479
}
480
480
481
481
#[ test]
482
482
fn test_str_add ( ) {
483
- let a = String :: from_str ( "12345" ) ;
483
+ let a = "12345" . to_string ( ) ;
484
484
let b = a + "2" ;
485
- let b = b + String :: from_str ( "2" ) ;
485
+ let b = b + "2" . to_string ( ) ;
486
486
assert_eq ! ( b. len( ) , 7 ) ;
487
487
assert_eq ! ( b. as_slice( ) , "1234522" ) ;
488
488
}
0 commit comments