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~5 ConcreteComposite%add_child proc~test_get_child->none~add_child~5 none~get_child~27 ConcreteComposite%get_child proc~test_get_child->none~get_child~27 true true proc~test_get_child->true none~at~286 StringCompositeMap%at none~add_child~5->none~at~286 none~insert~181 StringCompositeMap%insert none~add_child~5->none~insert~181 push_back push_back none~add_child~5->push_back none~get_child_by_index~3 ConcreteComposite%get_child_by_index none~get_child~27->none~get_child_by_index~3 none~get_child_by_name~3 ConcreteComposite%get_child_by_name none~get_child~27->none~get_child_by_name~3 none~find~58 StringCompositeMap%find none~at~286->none~find~58 none~get_child_by_index~3->none~get_child~27 of of none~get_child_by_index~3->of none~get_child_by_name~3->none~at~286 none~insert_pair~18 StringCompositeMap%insert_pair none~insert~181->none~insert_pair~18

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