Test_Attribute.pf Source File


This file depends on

sourcefile~~test_attribute.pf~~EfferentGraph sourcefile~test_attribute.pf Test_Attribute.pf sourcefile~attribute.f90 Attribute.F90 sourcefile~test_attribute.pf->sourcefile~attribute.f90 sourcefile~pfio_constants.f90 pFIO_Constants.F90 sourcefile~test_attribute.pf->sourcefile~pfio_constants.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~attribute.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfio_utilities.f90 pFIO_Utilities.F90 sourcefile~attribute.f90->sourcefile~pfio_utilities.f90 sourcefile~unlimitedentity.f90 UnlimitedEntity.F90 sourcefile~attribute.f90->sourcefile~unlimitedentity.f90 sourcefile~mapl_errorhandling.f90 MAPL_ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~pfio_utilities.f90->sourcefile~pfio_constants.f90 sourcefile~pfio_utilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_constants.f90 sourcefile~unlimitedentity.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_utilities.f90 sourcefile~mapl_errorhandling.f90->sourcefile~mapl_throw.f90

Source Code

module Test_Attribute
   use funit
   !use pfunit for mpi
  
   use pFIO_AttributeMod
   use pFIO_ConstantsMod
   use, intrinsic :: iso_fortran_env, only: INT32, INT64
   use, intrinsic :: iso_fortran_env, only: REAL32, REAL64
   implicit none

contains

   @test
   subroutine test_equal_shape()
      type (Attribute) :: a
      type (Attribute) :: b

      a = Attribute(1)
      b = Attribute([1,2])

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertFalse(a == b)
      @assertTrue(a /= b)

   end subroutine test_equal_shape

   @test
   subroutine test_equal_type()
      type (Attribute) :: a
      type (Attribute) :: b

      a = Attribute(1)
      b = Attribute(1.)

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertFalse(a == b)
      @assertTrue(a /= b)

   end subroutine test_equal_type

   @test
   subroutine test_equal_values()
      type (Attribute) :: a
      type (Attribute) :: b
      character(len=:),allocatable :: c1,c2

      a = Attribute(1.)
      b = Attribute(2.)

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertFalse(a == b)
      @assertTrue(a /= b)

      a = Attribute([.true., .false.])
      b = Attribute([.true., .true.])

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertFalse(a == b)
      @assertTrue(a /= b)

      c1 = 'a'
      c2 = 'a'
      a = Attribute(c1)
      b = Attribute(c2)

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertFalse(a /= b)
      @assertTrue(a == b)

      c1 = 'abcd'
      c2 = 'abcde'
      a = Attribute(c1)
      b = Attribute(c2)

      @assertTrue(a == a)
      @assertFalse(a /= a)
      @assertTrue(a /= b)
      @assertFalse(a == b)

   end subroutine test_equal_values

   @test
   subroutine test_serialize()
      type (Attribute) :: a
      type (Attribute) :: b

      integer,allocatable :: buffer(:)

      a = Attribute(10)
      call a%serialize(buffer)
      call Attribute_deserialize(buffer, b)
      @assertTrue(a==b)
      deallocate(buffer)

      a = Attribute([10,20,30])
      call a%serialize(buffer)
      call Attribute_deserialize(buffer, b)
      @assertTrue(a==b)
      deallocate(buffer)

      a = Attribute([.true.,.false.])
      call a%serialize(buffer)
      call Attribute_deserialize(buffer, b)
      @assertTrue(a==b)
      deallocate(buffer)

      a = Attribute('abcd')
      call a%serialize(buffer)
      call Attribute_deserialize(buffer, b)
      @assertTrue(a==b)
      deallocate(buffer)

      a = Attribute('abcdefgh')
      call a%serialize(buffer)
      call Attribute_deserialize(buffer, b)
      @assertTrue(a==b)
      deallocate(buffer)

   end subroutine test_serialize

end module Test_Attribute