@@ -463,6 +463,40 @@ subroutine test_iachar
463
463
call check(code == iachar (" F" ))
464
464
end subroutine test_iachar
465
465
466
+ subroutine test_move
467
+ type (string_type) :: from_string
468
+ type (string_type) :: to_string
469
+ character (len= :), allocatable :: from_char
470
+
471
+ from_string = " Move This String"
472
+ from_char = " Move This Char"
473
+ call check(from_string == " Move This String" .and. to_string == " " .and. &
474
+ & from_char == " Move This Char" , " move: test_case 1" )
475
+
476
+ ! string_type (allocated) --> string_type (not allocated)
477
+ call move(from_string, to_string)
478
+ call check(from_string == " " .and. to_string == " Move This String" , " move: test_case 2" )
479
+
480
+ ! character (allocated) --> string_type (not allocated)
481
+ call move(from_char, from_string)
482
+ call check(.not. allocated (from_char) .and. from_string == " Move This Char" , &
483
+ & " move: test_case 3" )
484
+
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" )
488
+
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" , &
492
+ & " move: test_case 5" )
493
+
494
+ ! character (allocated) --> string_type (allocated)
495
+ call move(from_char, from_string)
496
+ call check(.not. allocated (from_char) .and. from_string == " " , " move: test_case 6" )
497
+
498
+ end subroutine test_move
499
+
466
500
end module test_string_intrinsic
467
501
468
502
program tester
@@ -485,5 +519,6 @@ program tester
485
519
call test_char
486
520
call test_ichar
487
521
call test_iachar
522
+ call test_move
488
523
489
524
end program tester
0 commit comments