|
2 | 2 | module test_insert_at
|
3 | 3 | use stdlib_error, only: check
|
4 | 4 | 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(==) |
6 | 6 | use stdlib_ascii, only: to_string
|
7 | 7 | implicit none
|
8 | 8 |
|
@@ -345,6 +345,38 @@ subroutine test_insert_at_list
|
345 | 345 |
|
346 | 346 | end subroutine test_insert_at_list
|
347 | 347 |
|
| 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 | + |
348 | 380 | ! compares input stringlist 'list' with an array of consecutive integers
|
349 | 381 | ! array is 'first' inclusive and 'last' exclusive
|
350 | 382 | subroutine compare_list(list, first, last, call_number)
|
@@ -379,5 +411,6 @@ program tester
|
379 | 411 | call test_insert_at_string_3
|
380 | 412 | call test_insert_at_array
|
381 | 413 | call test_insert_at_list
|
| 414 | + call test_constructor |
382 | 415 |
|
383 | 416 | end program tester
|
0 commit comments