@@ -464,14 +464,14 @@ subroutine test_iachar
464
464
end subroutine test_iachar
465
465
466
466
subroutine test_move
467
- type (string_type) :: from_string
468
- type (string_type) :: to_string
469
- character (len= :), allocatable :: from_char
467
+ type (string_type) :: from_string, to_string
468
+ character (len= :), allocatable :: from_char, to_char
470
469
471
470
from_string = " Move This String"
472
471
from_char = " Move This Char"
473
472
call check(from_string == " Move This String" .and. to_string == " " .and. &
474
- & from_char == " Move This Char" , " move: test_case 1" )
473
+ & from_char == " Move This Char" .and. .not. allocated (to_char), &
474
+ & " move: test_case 1" )
475
475
476
476
! string_type (allocated) --> string_type (not allocated)
477
477
call move(from_string, to_string)
@@ -483,17 +483,27 @@ subroutine test_move
483
483
& " move: test_case 3" )
484
484
485
485
! string_type (allocated) --> character (not allocated)
486
- call move(to_string, from_char )
487
- call check(to_string == " " .and. from_char == " Move This String" , " move: test_case 4" )
486
+ call move(to_string, to_char )
487
+ call check(to_string == " " .and. to_char == " Move This String" , " move: test_case 4" )
488
488
489
489
! character (allocated) --> string_type (allocated)
490
- call move(from_char , from_string)
491
- call check(.not. allocated (from_char ) .and. from_string == " Move This String" , &
490
+ call move(to_char , from_string)
491
+ call check(.not. allocated (to_char ) .and. from_string == " Move This String" , &
492
492
& " move: test_case 5" )
493
493
494
+ from_char = " new char"
494
495
! character (allocated) --> string_type (allocated)
495
496
call move(from_char, from_string)
496
- call check(.not. allocated (from_char) .and. from_string == " " , " move: test_case 6" )
497
+ call check(.not. allocated (from_char) .and. from_string == " new char" , " move: test_case 6" )
498
+
499
+ ! character (unallocated) --> string_type (allocated)
500
+ call move(from_char, from_string)
501
+ call check(from_string == " " , " move: test_case 7" )
502
+
503
+ from_string = " moving to self"
504
+ ! string_type (allocated) --> string_type (allocated)
505
+ call move(from_string, from_string)
506
+ call check(from_string == " " , " move: test_case 8" )
497
507
498
508
end subroutine test_move
499
509
0 commit comments