Test_VarSpec.pf Source File


This file depends on

sourcefile~~test_varspec.pf~~EfferentGraph sourcefile~test_varspec.pf Test_VarSpec.pf sourcefile~varspec.f90 VarSpec.F90 sourcefile~test_varspec.pf->sourcefile~varspec.f90 sourcefile~constants.f90 Constants.F90 sourcefile~varspec.f90->sourcefile~constants.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~varspec.f90->sourcefile~errorhandling.f90 sourcefile~pflogger_stub.f90 pflogger_stub.F90 sourcefile~varspec.f90->sourcefile~pflogger_stub.f90 sourcefile~varspectype.f90 VarSpecType.F90 sourcefile~varspec.f90->sourcefile~varspectype.f90 sourcefile~internalconstants.f90 InternalConstants.F90 sourcefile~constants.f90->sourcefile~internalconstants.f90 sourcefile~mathconstants.f90 MathConstants.F90 sourcefile~constants.f90->sourcefile~mathconstants.f90 sourcefile~physicalconstants.f90 PhysicalConstants.F90 sourcefile~constants.f90->sourcefile~physicalconstants.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~pfl_keywordenforcer.f90 PFL_KeywordEnforcer.F90 sourcefile~pflogger_stub.f90->sourcefile~pfl_keywordenforcer.f90 sourcefile~wraparray.f90 WrapArray.F90 sourcefile~pflogger_stub.f90->sourcefile~wraparray.f90 sourcefile~varspectype.f90->sourcefile~errorhandling.f90 sourcefile~oomph.f90 oomph.F90 sourcefile~varspectype.f90->sourcefile~oomph.f90 sourcefile~abstractstateitemspec.f90 AbstractStateItemSpec.F90 sourcefile~oomph.f90->sourcefile~abstractstateitemspec.f90 sourcefile~connectionpoint.f90 ConnectionPoint.F90 sourcefile~oomph.f90->sourcefile~connectionpoint.f90 sourcefile~dimspec.f90 DimSpec.F90 sourcefile~oomph.f90->sourcefile~dimspec.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~oomph.f90->sourcefile~fieldspec.f90 sourcefile~horizontalstaggerloc.f90 HorizontalStaggerLoc.F90 sourcefile~oomph.f90->sourcefile~horizontalstaggerloc.f90 sourcefile~ungriddeddimspec.f90 UngriddedDimSpec.F90 sourcefile~oomph.f90->sourcefile~ungriddeddimspec.f90 sourcefile~verticalstaggerloc.f90 VerticalStaggerLoc.F90 sourcefile~oomph.f90->sourcefile~verticalstaggerloc.f90 sourcefile~physicalconstants.f90->sourcefile~mathconstants.f90

Source Code

module Test_VarSpec
   use pfunit
   use MAPL_VarSpecMod
   use esmf
   implicit none

contains

   @test
   subroutine test_simple_constructor()
      integer :: status
      type (MAPL_VarSpec), pointer :: specs(:) => null()
      character(:), allocatable :: units
      character(ESMF_MAXSTR) :: found_short_name, found_units

      units='barn'
      call MAPL_VarSpecCreateInList(specs, &
           short_name='fred', &
           units = units, &
           rc=status)
      @assertEqual(0, status)

      @assertEqual(1, size(specs))

      call MAPL_VarSpecGet(specs(1), short_name=found_short_name, units=found_units)
      @assertEqual('fred', trim(found_short_name))
      @assertEqual(units, found_units)

   end subroutine test_simple_constructor


   @test
   subroutine test_add_spec_grows_container()
      integer :: status
      type (MAPL_VarSpec), pointer :: specs(:) => null()
      character(:), allocatable :: units
      integer :: idx

      units='barn'
      call MAPL_VarSpecCreateInList(specs, &
           short_name='fred', &
           units = units, &
           rc=status)
      units='barn'
      call MAPL_VarSpecCreateInList(specs, &
           short_name='barney', &
           units = units, &
           rc=status)

      @assertEqual(2, size(specs))

      idx = MAPL_VarSpecGetIndex(specs, name='fred', rc=status)
      @assertEqual(0, status)
      @assertEqual(1, idx)

      idx = MAPL_VarSpecGetIndex(specs, name='barney', rc=status)
      @assertEqual(0, status)
      @assertEqual(2, idx)
      
   end subroutine test_add_spec_grows_container
   
end module Test_VarSpec