Skip to content

Commit

Permalink
Include the len keyword in length type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanchihwang committed Mar 4, 2025
1 parent 491ef13 commit 9adec5c
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions test/unit/fortran/src/core_utils/test_string_core_utils.pf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subroutine test_stringify_empty_arrays()
use funit
use string_core_utils, only: core_stringify

character(128), allocatable :: carr(:)
character(len=128), allocatable :: carr(:)
integer(int32), allocatable :: i32arr(:)
integer(int64), allocatable :: i64arr(:)
logical, allocatable :: larr(:)
Expand All @@ -95,20 +95,20 @@ subroutine test_stringify_character_array()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator = '<'
character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_default_separator = &
character(len=*), parameter :: custom_separator = '<'
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_default_separator = &
'Talc, Gypsum, Calcite, Fluorite, Apatite, Orthoclase, Quartz, Topaz, Corundum, Diamond'
character(*), parameter :: expected_custom_separator = &
character(len=*), parameter :: expected_custom_separator = &
'Talc<Gypsum<Calcite<Fluorite<Apatite<Orthoclase<Quartz<Topaz<Corundum<Diamond'
character(*), parameter :: expected_custom_separator_with_spaces = &
character(len=*), parameter :: expected_custom_separator_with_spaces = &
'Talc < Gypsum < Calcite < Fluorite < Apatite < Orthoclase < Quartz < Topaz < Corundum < Diamond'

character(128), allocatable :: carr(:)
character(len=128), allocatable :: carr(:)

allocate(carr(10))

carr(:) = [ character(len(carr)) :: &
carr(:) = [ character(len=len(carr)) :: &
' Talc', 'Gypsum', 'Calcite', 'Fluorite', 'Apatite', &
'Orthoclase', 'Quartz', ' Topaz', 'Corundum', 'Diamond' ]

Expand All @@ -126,13 +126,13 @@ subroutine test_stringify_integer_array()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator = '<'
character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_default_separator = &
character(len=*), parameter :: custom_separator = '<'
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_default_separator = &
'-10000, -1000, -100, -10, -1, 1, 10, 100, 1000, 10000'
character(*), parameter :: expected_custom_separator = &
character(len=*), parameter :: expected_custom_separator = &
'-10000<-1000<-100<-10<-1<1<10<100<1000<10000'
character(*), parameter :: expected_custom_separator_with_spaces = &
character(len=*), parameter :: expected_custom_separator_with_spaces = &
'-10000 < -1000 < -100 < -10 < -1 < 1 < 10 < 100 < 1000 < 10000'

integer(int32), allocatable :: i32arr(:)
Expand Down Expand Up @@ -160,14 +160,14 @@ subroutine test_stringify_integer_extreme_values()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_int32_default_separator = &
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_int32_default_separator = &
'-2147483647, -1000, -100, -10, -1, 1, 10, 100, 1000, 2147483647'
character(*), parameter :: expected_int64_default_separator = &
character(len=*), parameter :: expected_int64_default_separator = &
'-9223372036854775807, -1000, -100, -10, -1, 1, 10, 100, 1000, 9223372036854775807'
character(*), parameter :: expected_int32_custom_separator_with_spaces = &
character(len=*), parameter :: expected_int32_custom_separator_with_spaces = &
'-2147483647 < -1000 < -100 < -10 < -1 < 1 < 10 < 100 < 1000 < 2147483647'
character(*), parameter :: expected_int64_custom_separator_with_spaces = &
character(len=*), parameter :: expected_int64_custom_separator_with_spaces = &
'-9223372036854775807 < -1000 < -100 < -10 < -1 < 1 < 10 < 100 < 1000 < 9223372036854775807'

integer(int32), allocatable :: i32arr(:)
Expand All @@ -193,15 +193,15 @@ subroutine test_stringify_floating_point_array()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator = '<'
character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_default_separator = &
character(len=*), parameter :: custom_separator = '<'
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_default_separator = &
'-10000.000000, -1000.000000, -100.000000, -10.000000, -1.000000, ' // &
' 1.000000, 10.000000, 100.000000, 1000.000000, 10000.000000'
character(*), parameter :: expected_custom_separator = &
character(len=*), parameter :: expected_custom_separator = &
'-10000.000000< -1000.000000< -100.000000< -10.000000< -1.000000<' // &
' 1.000000< 10.000000< 100.000000< 1000.000000< 10000.000000'
character(*), parameter :: expected_custom_separator_with_spaces = &
character(len=*), parameter :: expected_custom_separator_with_spaces = &
'-10000.000000 < -1000.000000 < -100.000000 < -10.000000 < -1.000000 < ' // &
' 1.000000 < 10.000000 < 100.000000 < 1000.000000 < 10000.000000'

Expand Down Expand Up @@ -231,11 +231,11 @@ subroutine test_stringify_floating_point_scientific_notation()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_default_separator = &
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_default_separator = &
'-1.000000E+05, -1.000000E+03, -1.000000E+02, -1.000000E+01, -1.000000E+00, ' // &
' 1.000000E+00, 1.000000E+01, 1.000000E+02, 1.000000E+03, 1.000000E+05'
character(*), parameter :: expected_custom_separator_with_spaces = &
character(len=*), parameter :: expected_custom_separator_with_spaces = &
'-1.000000E+05 < -1.000000E+03 < -1.000000E+02 < -1.000000E+01 < -1.000000E+00 < ' // &
' 1.000000E+00 < 1.000000E+01 < 1.000000E+02 < 1.000000E+03 < 1.000000E+05'

Expand All @@ -260,17 +260,17 @@ subroutine test_stringify_floating_point_extreme_values()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator_with_spaces = ' < '
character(*), parameter :: expected_real32_default_separator = &
character(len=*), parameter :: custom_separator_with_spaces = ' < '
character(len=*), parameter :: expected_real32_default_separator = &
'-3.402823E+38, -1.000000E+03, -1.000000E+02, -1.000000E+01, -1.000000E+00, ' // &
' 1.000000E+00, 1.000000E+01, 1.000000E+02, 1.000000E+03, 3.402823E+38'
character(*), parameter :: expected_real64_default_separator = &
character(len=*), parameter :: expected_real64_default_separator = &
'-9.999999E+99, -1.000000E+03, -1.000000E+02, -1.000000E+01, -1.000000E+00, ' // &
' 1.000000E+00, 1.000000E+01, 1.000000E+02, 1.000000E+03, 9.999999E+99'
character(*), parameter :: expected_real32_custom_separator_with_spaces = &
character(len=*), parameter :: expected_real32_custom_separator_with_spaces = &
'-3.402823E+38 < -1.000000E+03 < -1.000000E+02 < -1.000000E+01 < -1.000000E+00 < ' // &
' 1.000000E+00 < 1.000000E+01 < 1.000000E+02 < 1.000000E+03 < 3.402823E+38'
character(*), parameter :: expected_real64_custom_separator_with_spaces = &
character(len=*), parameter :: expected_real64_custom_separator_with_spaces = &
'-9.999999E+99 < -1.000000E+03 < -1.000000E+02 < -1.000000E+01 < -1.000000E+00 < ' // &
' 1.000000E+00 < 1.000000E+01 < 1.000000E+02 < 1.000000E+03 < 9.999999E+99'

Expand All @@ -296,13 +296,13 @@ subroutine test_stringify_logical_array()
use funit
use string_core_utils, only: core_stringify

character(*), parameter :: custom_separator = '.or.'
character(*), parameter :: custom_separator_with_spaces = ' .or. '
character(*), parameter :: expected_default_separator = &
character(len=*), parameter :: custom_separator = '.or.'
character(len=*), parameter :: custom_separator_with_spaces = ' .or. '
character(len=*), parameter :: expected_default_separator = &
'T, F, T, F, T, F, T, F, T, F'
character(*), parameter :: expected_custom_separator = &
character(len=*), parameter :: expected_custom_separator = &
'T.or.F.or.T.or.F.or.T.or.F.or.T.or.F.or.T.or.F'
character(*), parameter :: expected_custom_separator_with_spaces = &
character(len=*), parameter :: expected_custom_separator_with_spaces = &
'T .or. F .or. T .or. F .or. T .or. F .or. T .or. F .or. T .or. F'

logical, allocatable :: larr(:)
Expand Down

0 comments on commit 9adec5c

Please sign in to comment.