B.5.4 Character Class Unit Test Program

This lightly commented program performs a unit test on the Character Class.

program Unit_Test

  use Caesar_Character_Class
  implicit none

  type(character,10) :: C
  type(character,20), pointer, dimension(:,:,:) :: C3

  ! Initializations.

  call Initialize (C)
  call Initialize (C3, 3, 4, 5)

  ! Character tests.

  VERIFY(Valid_State(C),0)
  VERIFY(Valid_State(C3),0)
  write (6,*) 'C         = ', C
  write (6,*) 'C3(1,1,1) = ', C3(1,1,1)

  C = 'Test Value'
  C3(1,1,1) = 'Test Value'

  VERIFY(Valid_State(C),0)
  VERIFY(Valid_State(C3),0)
  write (6,*) 'C         = ', C
  write (6,*) 'C3(1,1,1) = ', C3(1,1,1)

  ! The bottom line is that there are really no invalid characters. The
  ! Valid_State_Character routine is primarily added for completeness.

  ! Finalizations.

  call Finalize (C)
  call Finalize (C3)

  ! Output scalar value again.

  write (6,*) 'C         = ', C

  ! Should be invalid.

  write(6,*) 'Valid_State(C) =', Valid_State(C)

end



Michael L. Hall