Skip to content

Commit 8ed81c0

Browse files
committed
added test cases for constructor stringlist_type()
1 parent 35b28f5 commit 8ed81c0

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/tests/stringlist/test_insert_at.f90

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
module test_insert_at
33
use stdlib_error, only: check
44
use stdlib_string_type, only: string_type, operator(//), operator(==)
5-
use stdlib_stringlist, only: stringlist_type, fidx, bidx, list_head, list_tail
5+
use stdlib_stringlist, only: stringlist_type, fidx, bidx, list_head, list_tail, operator(==)
66
use stdlib_ascii, only: to_string
77
implicit none
88

@@ -345,6 +345,38 @@ subroutine test_insert_at_list
345345

346346
end subroutine test_insert_at_list
347347

348+
subroutine test_constructor
349+
type(stringlist_type) :: work_list
350+
character(len=4), allocatable :: carray(:)
351+
type(string_type), allocatable :: sarray(:)
352+
353+
write (*,*) "test_constructor: Starting test case 1!"
354+
work_list = stringlist_type()
355+
allocate( carray(0) )
356+
allocate( sarray(0) )
357+
call check( work_list == carray, "test_constructor:&
358+
& test_case 1 work_list == carray" )
359+
call check( work_list == sarray, "test_constructor:&
360+
& test_case 1 work_list == sarray" )
361+
362+
write (*,*) "test_constructor: Starting test case 2!"
363+
carray = [ '#1', '#2', '#3', '#4' ]
364+
sarray = [ string_type('#1'), string_type('#2'), string_type('#3'), string_type('#4') ]
365+
work_list = stringlist_type( carray )
366+
call check( work_list == carray, "test_constructor:&
367+
& test_case 2 work_list == carray" )
368+
call check( work_list == sarray, "test_constructor:&
369+
& test_case 2 work_list == sarray" )
370+
371+
write (*,*) "test_constructor: Starting test case 3!"
372+
work_list = stringlist_type( sarray )
373+
call check( work_list == carray, "test_constructor:&
374+
& test_case 3 work_list == carray" )
375+
call check( work_list == sarray, "test_constructor:&
376+
& test_case 3 work_list == sarray" )
377+
378+
end subroutine test_constructor
379+
348380
! compares input stringlist 'list' with an array of consecutive integers
349381
! array is 'first' inclusive and 'last' exclusive
350382
subroutine compare_list(list, first, last, call_number)
@@ -379,5 +411,6 @@ program tester
379411
call test_insert_at_string_3
380412
call test_insert_at_array
381413
call test_insert_at_list
414+
call test_constructor
382415

383416
end program tester

0 commit comments

Comments
 (0)