Test_ConcreteComposite.pf Source File


This file depends on

sourcefile~~test_concretecomposite.pf~~EfferentGraph sourcefile~test_concretecomposite.pf Test_ConcreteComposite.pf sourcefile~abstractcomposite.f90 AbstractComposite.F90 sourcefile~test_concretecomposite.pf->sourcefile~abstractcomposite.f90 sourcefile~abstractframeworkcomponent.f90 AbstractFrameworkComponent.F90 sourcefile~test_concretecomposite.pf->sourcefile~abstractframeworkcomponent.f90 sourcefile~concretecomposite.f90 ConcreteComposite.F90 sourcefile~test_concretecomposite.pf->sourcefile~concretecomposite.f90 sourcefile~maplgenericcomponent.f90 MaplGenericComponent.F90 sourcefile~test_concretecomposite.pf->sourcefile~maplgenericcomponent.f90 sourcefile~surrogateframeworkcomponent.f90 SurrogateFrameworkComponent.F90 sourcefile~abstractframeworkcomponent.f90->sourcefile~surrogateframeworkcomponent.f90 sourcefile~concretecomposite.f90->sourcefile~abstractcomposite.f90 sourcefile~concretecomposite.f90->sourcefile~abstractframeworkcomponent.f90 sourcefile~stringcompositemap.f90 StringCompositeMap.F90 sourcefile~concretecomposite.f90->sourcefile~stringcompositemap.f90 sourcefile~maplgenericcomponent.f90->sourcefile~abstractframeworkcomponent.f90 sourcefile~maplgenericcomponent.f90->sourcefile~concretecomposite.f90 sourcefile~abstractcomponent.f90 AbstractComponent.F90 sourcefile~maplgenericcomponent.f90->sourcefile~abstractcomponent.f90 sourcefile~baseframeworkcomponent.f90 BaseFrameworkComponent.F90 sourcefile~maplgenericcomponent.f90->sourcefile~baseframeworkcomponent.f90 sourcefile~compositecomponent.f90 CompositeComponent.F90 sourcefile~maplgenericcomponent.f90->sourcefile~compositecomponent.f90 sourcefile~entrypointvector.f90 EntryPointVector.F90 sourcefile~maplgenericcomponent.f90->sourcefile~entrypointvector.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~maplgenericcomponent.f90->sourcefile~errorhandling.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~maplgenericcomponent.f90->sourcefile~keywordenforcer.f90 sourcefile~maplcomponent.f90 MaplComponent.F90 sourcefile~maplgenericcomponent.f90->sourcefile~maplcomponent.f90 sourcefile~maplgrid.f90 MaplGrid.F90 sourcefile~maplgenericcomponent.f90->sourcefile~maplgrid.f90 sourcefile~openmp_support.f90 OpenMP_Support.F90 sourcefile~maplgenericcomponent.f90->sourcefile~openmp_support.f90 sourcefile~pflogger_stub.f90 pflogger_stub.F90 sourcefile~maplgenericcomponent.f90->sourcefile~pflogger_stub.f90 sourcefile~runentrypoint.f90 RunEntryPoint.F90 sourcefile~maplgenericcomponent.f90->sourcefile~runentrypoint.f90 sourcefile~baseframeworkcomponent.f90->sourcefile~abstractframeworkcomponent.f90 sourcefile~baseframeworkcomponent.f90->sourcefile~abstractcomponent.f90 sourcefile~baseframeworkcomponent.f90->sourcefile~compositecomponent.f90 sourcefile~baseframeworkcomponent.f90->sourcefile~maplgrid.f90 sourcefile~baseframeworkcomponent.f90->sourcefile~surrogateframeworkcomponent.f90 sourcefile~componentspecification.f90 ComponentSpecification.F90 sourcefile~baseframeworkcomponent.f90->sourcefile~componentspecification.f90 sourcefile~compositecomponent.f90->sourcefile~abstractcomposite.f90 sourcefile~compositecomponent.f90->sourcefile~abstractframeworkcomponent.f90 sourcefile~compositecomponent.f90->sourcefile~concretecomposite.f90 sourcefile~entrypointvector.f90->sourcefile~runentrypoint.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~maplcomponent.f90->sourcefile~errorhandling.f90 sourcefile~maplcomponent.f90->sourcefile~keywordenforcer.f90 sourcefile~maplcomponent.f90->sourcefile~pflogger_stub.f90 sourcefile~maplcomponent.f90->sourcefile~surrogateframeworkcomponent.f90 sourcefile~basecomponent.f90 BaseComponent.F90 sourcefile~maplcomponent.f90->sourcefile~basecomponent.f90 sourcefile~maplgrid.f90->sourcefile~errorhandling.f90 sourcefile~maplgrid.f90->sourcefile~keywordenforcer.f90 sourcefile~maplgrid.f90->sourcefile~pflogger_stub.f90 sourcefile~constants.f90 Constants.F90 sourcefile~maplgrid.f90->sourcefile~constants.f90 sourcefile~mapl_sort.f90 MAPL_Sort.F90 sourcefile~maplgrid.f90->sourcefile~mapl_sort.f90 sourcefile~openmp_support.f90->sourcefile~entrypointvector.f90 sourcefile~openmp_support.f90->sourcefile~keywordenforcer.f90 sourcefile~openmp_support.f90->sourcefile~maplgrid.f90 sourcefile~openmp_support.f90->sourcefile~runentrypoint.f90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~openmp_support.f90->sourcefile~base_base.f90 sourcefile~callbackmap.f90 CallbackMap.F90 sourcefile~openmp_support.f90->sourcefile~callbackmap.f90 sourcefile~mapl_esmf_interfaces.f90 MAPL_ESMF_Interfaces.F90 sourcefile~openmp_support.f90->sourcefile~mapl_esmf_interfaces.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~openmp_support.f90->sourcefile~mapl_exceptionhandling.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~stringcompositemap.f90->sourcefile~abstractcomposite.f90

Source Code

module Test_ConcreteComposite
   use funit
   use mapl_ConcreteComposite
   use mapl_MaplGenericComponent
   use mapl_AbstractComposite
   use mapl_AbstractFrameworkComponent
   implicit none

   type, extends(MaplGenericComponent) :: NamedComponent
      character(:), allocatable :: name
   end type NamedComponent

contains

   @test
   subroutine test_get_parent_orphan()
      type(ConcreteComposite) :: composite
      type(MaplGenericComponent) :: component

      composite = ConcreteComposite(component)
      @assert_that(associated(composite%get_parent()), is(false()))

   end subroutine test_get_parent_orphan

   @test
   subroutine test_get_parent()
      type(ConcreteComposite) :: child
      type(ConcreteComposite), target :: parent
      type(MaplGenericComponent) :: component

      class(AbstractComposite), pointer :: ptr
      
      parent = ConcreteComposite(component)
      ptr => parent
      child = ConcreteComposite(component, parent)
      
      ptr => child%get_parent()
      @assert_that(associated(ptr), is(true()))
      @assert_that(associated(ptr,parent), is(true()))

   end subroutine test_get_parent

   @test
   subroutine test_get_component()
      type(ConcreteComposite) :: composite

      type(NamedComponent) :: component
      class(AbstractFrameworkComponent), pointer :: component_ptr

      component%name = 'foo'
      composite = ConcreteComposite(component)
      component_ptr => composite%get_component()
      select type (component_ptr)
      type is (NamedComponent)
         @assert_that(component_ptr%name, is('foo'))
      class default
         @assert_that('incorrect type', .true., is(false()))
      end select

   end subroutine test_get_component

   @test
   subroutine test_get_child()
      type(ConcreteComposite) :: child
      type(ConcreteComposite), target :: parent
      type(NamedComponent) :: P, A

      class(AbstractComposite), pointer :: ptr

      P%name = 'p'
      A%name = 'A'
      parent = ConcreteComposite(P)
      child = ConcreteComposite(A)
      ptr => parent%add_child('A', child)
      ptr => parent%get_child('A')

      @assert_that(associated(ptr), is(true()))
      select type (ptr)
      type is (ConcreteComposite)
         select type (q => ptr%get_component())
         type is (NamedComponent)
            @assert_that(q%name, is('A'))
         class default
            @assert_that('incorrect type', .true., is(false()))
         end select
      class default
         @assert_that('incorrect type', .true., is(false()))
      end select

   end subroutine test_get_child

end module Test_ConcreteComposite