@@ -4,7 +4,7 @@ module test_string_functions
44 use stdlib_error, only : check
55 use stdlib_string_type, only : string_type, assignment (= ), operator (==), &
66 to_lower, to_upper, to_title, to_sentence, reverse
7- use stdlib_strings, only: slice
7+ use stdlib_strings, only: slice, find
88 use stdlib_optval, only: optval
99 use stdlib_ascii, only : to_string
1010 implicit none
@@ -56,7 +56,7 @@ subroutine test_reverse_string
5656
5757 end subroutine test_reverse_string
5858
59- subroutine test_slice_string
59+ subroutine test_slice
6060 type (string_type) :: test_string
6161 test_string = " abcdefghijklmnopqrstuvwxyz"
6262
@@ -160,7 +160,20 @@ subroutine test_slice_string
160160 call check(slice(test_string) == " " , &
161161 " Slice, Empty string: no arguments provided" )
162162
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
164177
165178 subroutine test_slice_gen
166179 character (len=* ), parameter :: test = &
@@ -300,5 +313,6 @@ program tester
300313 call test_reverse_string
301314 call test_slice_string
302315 call test_slice_gen
316+ call test_find
303317
304318end program tester
0 commit comments