test_get_attribute_scalar Subroutine

public subroutine test_get_attribute_scalar()

Arguments

None

Calls

proc~~test_get_attribute_scalar~~CallsGraph proc~test_get_attribute_scalar test_get_attribute_scalar assertequal assertequal proc~test_get_attribute_scalar->assertequal asserttrue asserttrue proc~test_get_attribute_scalar->asserttrue none~add_attribute~3 FileMetadata%add_attribute proc~test_get_attribute_scalar->none~add_attribute~3 none~get_attribute~2 FileMetadata%get_attribute proc~test_get_attribute_scalar->none~get_attribute~2 none~get_shape UnlimitedEntity%get_shape proc~test_get_attribute_scalar->none~get_shape none~get_value UnlimitedEntity%get_value proc~test_get_attribute_scalar->none~get_value none~add_attribute_0d~2 FileMetadata%add_attribute_0d none~add_attribute~3->none~add_attribute_0d~2 none~add_attribute_1d~2 FileMetadata%add_attribute_1d none~add_attribute~3->none~add_attribute_1d~2 interface~mapl_assert MAPL_Assert none~get_attribute~2->interface~mapl_assert none~get_attribute Variable%get_attribute none~get_attribute~2->none~get_attribute proc~mapl_return MAPL_Return none~get_attribute~2->proc~mapl_return none~get_shape->proc~mapl_return none~get_value->proc~mapl_return none~add_attribute_0d~2->proc~mapl_return none~add_attribute~2 Variable%add_attribute none~add_attribute_0d~2->none~add_attribute~2 none~add_attribute_1d~2->proc~mapl_return none~add_attribute_1d~2->none~add_attribute~2 none~get_attribute->interface~mapl_assert none~get_attribute->proc~mapl_return none~at~226 StringAttributeMap%at none~get_attribute->none~at~226 at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d none~find~59 StringAttributeMap%find none~at~226->none~find~59

Source Code

   subroutine test_get_attribute_scalar()
      type (FileMetadata), target :: cf

      type (Attribute), pointer :: attr
      integer, allocatable :: shape(:)

      class (*), pointer :: value
      integer :: i = 4
      real(REAL32) :: x32 = 1.234
      real(REAL64) :: x64 = 2.345_REAL64
      logical :: flag = .true.
      character(len=*), parameter :: str = 'kitty'

      call cf%add_attribute('i', i)
      call cf%add_attribute('x32', x32)
      call cf%add_attribute('x64', x64)
      call cf%add_attribute('flag', flag)
      call cf%add_attribute('string', str)

      attr => cf%get_attribute('i')
      @assertTrue(associated(attr))
      shape = attr%get_shape()
      @assertEqual(EMPTY, shape)
      value => attr%get_value()
      @assertTrue(associated(value))
      select type (v => value)
      type is (integer)
         @assertEqual(i, v)
      class default
         @assertTrue(.false., 'incorrect type')
      end select

      attr => cf%get_attribute('x32')
      @assertTrue(associated(attr))
      shape = attr%get_shape()
      @assertEqual(EMPTY, shape)
      value => attr%get_value()
      @assertTrue(associated(value))
      select type (v => value)
      type is (real(REAL32))
         @assertEqual(x32, v)
      class default
         @assertTrue(.false., 'incorrect type')
      end select

      attr => cf%get_attribute('x64')
      @assertTrue(associated(attr))
      shape = attr%get_shape()
      @assertEqual(EMPTY, shape)
      value => attr%get_value()
      @assertTrue(associated(value))
      select type (v => value)
      type is (real(REAL64))
         @assertEqual(x64, v)
      class default
         @assertTrue(.false., 'incorrect type')
      end select

      attr => cf%get_attribute('flag')
      @assertTrue(associated(attr))
      shape = attr%get_shape()
      @assertEqual(EMPTY, shape)
      value => attr%get_value()
      @assertTrue(associated(value))
      select type (v => value)
      type is (logical)
         @assertTrue(flag .eqv. v)
      class default
         @assertTrue(.false., 'incorrect type')
      end select

      attr => cf%get_attribute('string')
      @assertTrue(associated(attr))
      shape = attr%get_shape()
      @assertEqual(EMPTY, shape)
      value => attr%get_value()
      @assertTrue(associated(value))
      select type (v => value)
      type is (character(len=*))
         @assertEqual(str, v)
      type is (StringWrap)
         @assertEqual(str, v%value)
      class default
         @assertTrue(.false., 'incorrect type')
      end select


   end subroutine test_get_attribute_scalar