@@ -3,7 +3,7 @@ module test_string_functions
3
3
use stdlib_error, only : check
4
4
use stdlib_string_type, only : string_type, assignment (= ), operator (==), &
5
5
to_lower, to_upper, to_title, to_sentence, reverse
6
- use stdlib_strings, only: slice
6
+ use stdlib_strings, only: slice, find
7
7
implicit none
8
8
9
9
contains
@@ -53,7 +53,7 @@ subroutine test_reverse_string
53
53
54
54
end subroutine test_reverse_string
55
55
56
- subroutine test_slice_string
56
+ subroutine test_slice
57
57
type (string_type) :: test_string
58
58
character (len= :), allocatable :: test_char
59
59
test_string = " abcdefghijklmnopqrstuvwxyz"
@@ -103,7 +103,20 @@ subroutine test_slice_string
103
103
call check(slice(test_char, 2 , 16 , 3 ) == " " , &
104
104
' function slice failed' , warn= .false. )
105
105
106
- end subroutine test_slice_string
106
+ end subroutine test_slice
107
+
108
+ subroutine test_find
109
+ type (string_type) :: test_string, test_pattern
110
+ test_string = " qwqwqwqwqwqwqw"
111
+ test_pattern = " qwq"
112
+ call check(find(test_string, test_pattern, 4 ) == 7 )
113
+ call check(find(test_string, test_pattern, 3 , .false. ) == 9 )
114
+ call check(find(test_string, test_pattern, 7 ) == 0 )
115
+ call check(find(" qwqwqwqwqwqwqw" , test_pattern) == 1 )
116
+ call check(find(test_string, " qwq" , 2 ) == 3 )
117
+ call check(find(" qwqwqwqwqwqwqw" , " qwq" , 2 , .false. ) == 5 )
118
+
119
+ end subroutine test_find
107
120
108
121
end module test_string_functions
109
122
@@ -117,6 +130,7 @@ program tester
117
130
call test_to_title_string
118
131
call test_to_sentence_string
119
132
call test_reverse_string
120
- call test_slice_string
133
+ call test_slice
134
+ call test_find
121
135
122
136
end program tester
0 commit comments