test_get_integer_digit Subroutine

public subroutine test_get_integer_digit()

Arguments

None

Calls

proc~~test_get_integer_digit~~CallsGraph proc~test_get_integer_digit test_get_integer_digit assertequal assertequal proc~test_get_integer_digit->assertequal proc~get_integer_digit get_integer_digit proc~test_get_integer_digit->proc~get_integer_digit

Source Code

   subroutine test_get_integer_digit()
      integer :: n
      integer, parameter :: NONDIGIT = -1
      integer, parameter :: ASCII_MIN = 0
      integer, parameter :: ASCII_MAX = 127
      integer, parameter :: ASCII_LT0 = iachar('0') - 1
      integer, parameter :: ASCII_GT9 = iachar('9') + 1
      character(len=10), parameter :: digit = '0123456789'
      character :: c

      do n = 1, len(digit)
         @assertEqual(n-1, get_integer_digit(digit(n:n)))
      end do

      do n = ASCII_MIN, ASCII_LT0
         c = achar(n)
         @assertEqual(NONDIGIT, get_integer_digit(c))
      end do

      do n = ASCII_GT9, ASCII_MAX
         c = achar(n)
         @assertEqual(NONDIGIT, get_integer_digit(c))
      end do
   end subroutine test_get_integer_digit