test_date Subroutine

public subroutine test_date()

Arguments

None

Calls

proc~~test_date~~CallsGraph proc~test_date test_date assert_that assert_that proc~test_date->assert_that false false proc~test_date->false proc~is_valid_date is_valid_date proc~test_date->proc~is_valid_date true true proc~test_date->true

Source Code

   subroutine test_date()

      integer :: date

      ! Obvious cases
      date = 20000101
      @assert_that(is_valid_date(date), is(true()))

      date = -1
      @assert_that(is_valid_date(date), is(false()))

      date = 20000000
      @assert_that(is_valid_date(date), is(false()))

      date = 20001301
      @assert_that(is_valid_date(date), is(false()))

      date = 20001232
      @assert_that(is_valid_date(date), is(false()))

      ! Month Tests

      ! 30-day months

      date = 12340431
      @assert_that(is_valid_date(date), is(false()))

      date = 12340631
      @assert_that(is_valid_date(date), is(false()))

      date = 12340931
      @assert_that(is_valid_date(date), is(false()))

      date = 12341131
      @assert_that(is_valid_date(date), is(false()))

      ! February tests

      date = 19000228
      @assert_that(is_valid_date(date), is(true()))

      date = 19000229
      @assert_that(is_valid_date(date), is(false()))

      date = 20000229
      @assert_that(is_valid_date(date), is(true()))

      date = 20000230
      @assert_that(is_valid_date(date), is(false()))

      date = 20010229
      @assert_that(is_valid_date(date), is(false()))

      date = 20040229
      @assert_that(is_valid_date(date), is(true()))

      date = 18910301
      @assert_that(is_valid_date(date), is(true()))

   end subroutine test_date