test_cstring Subroutine

public subroutine test_cstring()

Arguments

None

Calls

proc~~test_cstring~~CallsGraph proc~test_cstring test_cstring assertequal assertequal proc~test_cstring->assertequal proc~cstring cstring proc~test_cstring->proc~cstring

Source Code

   subroutine test_cstring()
      character(len=*), parameter :: fs = 'FOO_BAR'
      character(kind=c_char, len=80) :: cchs
      character(kind=kind(cchs)) :: cc
      integer :: n

      cchs = cstring(fs)
      @assertEqual(kind((cchs)), c_char, 'Wrong kind')
      n = len_trim(cchs)
      @assertEqual(n, len(fs)+1, 'cstring is incorrect length.')
      cc = cchs(n:n)
      @assertEqual(cc, c_null_char, 'Final character is not null.')
      @assertEqual(cchs(1:(n-1)), fs, 'Initial characters do not match.')

   end subroutine test_cstring