program dcstr_test
  use dc_types
  use dc_string
  use dc_trace
  implicit none

  integer:: i
  character(STRING), pointer :: carray(:) =>null()
  character(STRING) :: char

  call setdebug

  !
  ! Test for "Split"
  !
  call split('time=0.0', carray, '=')
  do i = 1, size(carray)
     write(*,*) 'carray(', i, ') = ', trim(carray(i))
  end do
  deallocate(carray)

  call split('  time = 0.0  ', carray, '')
  do i = 1, size(carray)
     write(*,*) 'carray(', i, ') = ', trim(carray(i))
  end do
  deallocate(carray)

  call split('time=0.0 ||$ x=1.0 ||$ y=hogehoge ', carray, '||$')
  do i = 1, size(carray)
     write(*,*) 'carray(', i, ') = ', trim(carray(i))
  end do
  deallocate(carray)

  call split('  time = 0.0  ', carray, '', 2)
  do i = 1, size(carray)
     write(*,*) 'carray(', i, ') = ', trim(carray(i))
  end do
  deallocate(carray)

  call split('time=0.0,x=1.0,y=0.1,z=10,m=8,l=9 ', carray, ',', 3)
  do i = 1, size(carray)
     write(*,*) 'carray(', i, ') = ', trim(carray(i))
  end do
  deallocate(carray)



  !
  ! Test for "StoA"
  !

  write(*,*) (/"hogehoge", "foo     ", "hero    "/)
  write(*,*) StoA("hogehoge", "foo", "hero")
  call printf(6, '%a, %a, %a, %a, %a, %a', &
       & ca=StoA("hogehoge", "foo", "hero", "uni"))
  call printf(6, '%*a', &
       & ca=StoA("hogehoge", "foo", "hero", "uni"), n=(/4/))
  call printf(6, '%*d', i=(/1, 2, 4/), n=(/2/))
  call printf(6, '%*r', r=(/(/1.0, 2.0, 4.0/)/), n=(/5/))
  char = cprintf('%*r %*a', r=(/1.0, 2.0, 4.0/), &
       & ca=StoA("hogehoge", "foo", "hero", "uni"), n=(/2,3/))
  write(*,*) char

end program dcstr_test
