test_is_valid_day Subroutine

public subroutine test_is_valid_day()

Arguments

None

Calls

proc~~test_is_valid_day~~CallsGraph proc~test_is_valid_day test_is_valid_day assertfalse assertfalse proc~test_is_valid_day->assertfalse asserttrue asserttrue proc~test_is_valid_day->asserttrue is_valid_day is_valid_day proc~test_is_valid_day->is_valid_day

Source Code

   subroutine test_is_valid_day()
      character(len=*), parameter :: FMT = '("day (",i4,", ",i2,", ",i2,")",a)'
      character(len=*), parameter :: SHOULD = ' should be valid.'
      character(len=*), parameter :: SHOULD_NOT = ' should not be valid.'
      character(len=255) :: error_message

      integer :: d, m, y
      d = 30; m = 4; y = 2023
      write(error_message, fmt=FMT) y, m, d, SHOULD
      @assertTrue(is_valid_day(y, m, d), trim(error_message))
      d = 31
      write(error_message, fmt=FMT) y, m, d, SHOULD_NOT
      @assertFalse(is_valid_day(y, m, d), trim(error_message))
      d = 29
      write(error_message, fmt=FMT) y, m, d, SHOULD
      @assertTrue(is_valid_day(y, m, d), trim(error_message))
      m = 2
      write(error_message, fmt=FMT) y, m, d, SHOULD_NOT
      @assertFalse(is_valid_day(y, m, d), trim(error_message))
      y = 2024
      write(error_message, fmt=FMT) y, m, d, SHOULD
      @assertTrue(is_valid_day(y, m, d), trim(error_message))
   end subroutine test_is_valid_day