Skip to content

Commit 9d72c69

Browse files
committed
made complete use of slice interface: added test cases for character sequence
1 parent ac607f1 commit 9d72c69

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/tests/string/test_string_functions.f90

+23-18
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,41 @@ end subroutine test_reverse_string
5555

5656
subroutine test_slice_string
5757
type(string_type) :: test_string
58+
character(len=:), allocatable :: test_char
5859
test_string = "abcdefghijklmnopqrstuvwxyz"
60+
test_char = "abcdefghijklmnopqrstuvwxyz"
5961

6062
call check(slice(test_string, 2, 16, 3) == "behkn", &
61-
'function slice failed', warn=.false.)
62-
call check(slice(test_string, 15, stride=-1) == "onmlkjihgfedcba", &
63-
'function slice failed', warn=.false.)
63+
'function slice failed', warn=.true.)
64+
call check(slice(test_char, 15, stride=-1) == "onmlkjihgfedcba", &
65+
'function slice failed', warn=.true.)
6466
call check(slice(test_string, last=22, stride=-1) == "zyxwv", &
65-
'function slice failed', warn=.false.)
66-
call check(slice(test_string, 7, 2) == "gfedcb", &
67-
'function slice failed', warn=.false.)
67+
'function slice failed', warn=.true.)
68+
call check(slice(test_char, 7, 2) == "gfedcb", &
69+
'function slice failed', warn=.true.)
6870
call check(slice(test_string, 7, 2, 1) == "", &
69-
'function slice failed', warn=.false.)
70-
call check(slice(test_string, 2, 6, -1) == "", &
71-
'function slice failed', warn=.false.)
71+
'function slice failed', warn=.true.)
72+
call check(slice(test_char, 2, 6, -1) == "", &
73+
'function slice failed', warn=.true.)
7274
call check(slice(test_string, stride=-1) == "zyxwvutsrqponmlkjihgfedcba", &
73-
'function slice failed', warn=.false.)
75+
'function slice failed', warn=.true.)
7476
call check(slice(test_string, 7, 7, -4) == "g", &
75-
'function slice failed', warn=.false.)
77+
'function slice failed', warn=.true.)
78+
call check(slice(test_char, 7, 7, 3) == "g", &
79+
'function slice failed', warn=.true.)
7680
call check(slice(test_string, 7, 7, 3) == "g", &
77-
'function slice failed', warn=.false.)
78-
call check(slice(test_string, 7, 7, 3) == "g", &
79-
'function slice failed', warn=.false.)
80-
call check(slice(test_string, 7, -10) == "gfedcba", &
81-
'function slice failed', warn=.false.)
81+
'function slice failed', warn=.true.)
82+
call check(slice(test_char, 7, -10) == "gfedcba", &
83+
'function slice failed', warn=.true.)
8284
call check(slice(test_string, 500, 22) == "zyxwv", &
83-
'function slice failed', warn=.false.)
85+
'function slice failed', warn=.true.)
8486

8587
test_string = ""
88+
test_char = ""
8689
call check(slice(test_string, 2, 16, 3) == "", &
87-
'function slice failed', warn=.false.)
90+
'function slice failed', warn=.true.)
91+
call check(slice(test_char, 2, 16, 3) == "", &
92+
'function slice failed', warn=.true.)
8893

8994
end subroutine test_slice_string
9095

0 commit comments

Comments
 (0)