test_read_whole_number_indexed Subroutine

public subroutine test_read_whole_number_indexed()

Arguments

None

Calls

proc~~test_read_whole_number_indexed~~CallsGraph proc~test_read_whole_number_indexed test_read_whole_number_indexed assertequal assertequal proc~test_read_whole_number_indexed->assertequal proc~read_whole_number_indexed read_whole_number_indexed proc~test_read_whole_number_indexed->proc~read_whole_number_indexed proc~get_integer_digit_from_string get_integer_digit_from_string proc~read_whole_number_indexed->proc~get_integer_digit_from_string proc~is_whole_number is_whole_number proc~read_whole_number_indexed->proc~is_whole_number proc~get_integer_digit get_integer_digit proc~get_integer_digit_from_string->proc~get_integer_digit

Source Code

   subroutine test_read_whole_number_indexed()
      character(len=11), parameter :: STRING = '12345678901'
      character(len=15), parameter :: BAD_STRING = '18The3.1415...'
      integer, parameter :: NOT_WHOLE_NUMBER = -1

      @assertEqual(12, read_whole_number_indexed(STRING, 1, 2))
      @assertEqual(90, read_whole_number_indexed(STRING, 9, 10))
      @assertEqual(7, read_whole_number_indexed(STRING, 7, 7))
      @assertEqual(1, read_whole_number_indexed(STRING, 10, 11))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, 2, 1))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, 1, 12))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, -1, 9))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, 1, -1))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, 0, 2))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(STRING, 2, 0))
      @assertEqual(18, read_whole_number_indexed(BAD_STRING, 1, 2))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 2, 3))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 3, 5))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 5, 5))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 5, 6))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 6, 11))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 7, 7))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed(BAD_STRING, 7, 8))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed('+800', 1, 3))
      @assertEqual(NOT_WHOLE_NUMBER, read_whole_number_indexed('-800', 1, 3))
   end subroutine test_read_whole_number_indexed