test_get_child Subroutine

public subroutine test_get_child()

Arguments

None

Calls

proc~~test_get_child~~CallsGraph proc~test_get_child test_get_child assert_that assert_that proc~test_get_child->assert_that false false proc~test_get_child->false get_component get_component proc~test_get_child->get_component none~add_child~2 ConcreteComposite%add_child proc~test_get_child->none~add_child~2 none~get_child~27 ConcreteComposite%get_child proc~test_get_child->none~get_child~27 true true proc~test_get_child->true none~at~34 StringCompositeMap%at none~add_child~2->none~at~34 none~insert~28 StringCompositeMap%insert none~add_child~2->none~insert~28 push_back push_back none~add_child~2->push_back none~get_child_by_index~2 ConcreteComposite%get_child_by_index none~get_child~27->none~get_child_by_index~2 none~get_child_by_name~2 ConcreteComposite%get_child_by_name none~get_child~27->none~get_child_by_name~2 none~find~5 StringCompositeMap%find none~at~34->none~find~5 none~get_child_by_index~2->none~get_child~27 of of none~get_child_by_index~2->of none~get_child_by_name~2->none~at~34 none~insert_pair~2 StringCompositeMap%insert_pair none~insert~28->none~insert_pair~2

Source Code

   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