@@ -4,7 +4,7 @@ module test_string_functions
4
4
use stdlib_error, only : check
5
5
use stdlib_string_type, only : string_type, assignment (= ), operator (==), &
6
6
to_lower, to_upper, to_title, to_sentence, reverse
7
- use stdlib_strings, only: slice
7
+ use stdlib_strings, only: slice, find
8
8
use stdlib_optval, only: optval
9
9
use stdlib_ascii, only : to_string
10
10
implicit none
@@ -56,7 +56,7 @@ subroutine test_reverse_string
56
56
57
57
end subroutine test_reverse_string
58
58
59
- subroutine test_slice_string
59
+ subroutine test_slice
60
60
type (string_type) :: test_string
61
61
test_string = " abcdefghijklmnopqrstuvwxyz"
62
62
@@ -160,7 +160,20 @@ subroutine test_slice_string
160
160
call check(slice(test_string) == " " , &
161
161
" Slice, Empty string: no arguments provided" )
162
162
163
- end subroutine test_slice_string
163
+ end subroutine test_slice
164
+
165
+ subroutine test_find
166
+ type (string_type) :: test_string, test_pattern
167
+ test_string = " qwqwqwqwqwqwqw"
168
+ test_pattern = " qwq"
169
+ call check(find(test_string, test_pattern, 4 ) == 7 )
170
+ call check(find(test_string, test_pattern, 3 , .false. ) == 9 )
171
+ call check(find(test_string, test_pattern, 7 ) == 0 )
172
+ call check(find(" qwqwqwqwqwqwqw" , test_pattern) == 1 )
173
+ call check(find(test_string, " qwq" , 2 ) == 3 )
174
+ call check(find(" qwqwqwqwqwqwqw" , " qwq" , 2 , .false. ) == 5 )
175
+
176
+ end subroutine test_find
164
177
165
178
subroutine test_slice_gen
166
179
character (len=* ), parameter :: test = &
@@ -300,5 +313,6 @@ program tester
300
313
call test_reverse_string
301
314
call test_slice_string
302
315
call test_slice_gen
316
+ call test_find
303
317
304
318
end program tester
0 commit comments