test_cptr_wrapper Subroutine

public subroutine test_cptr_wrapper()

Arguments

None

Calls

proc~~test_cptr_wrapper~~CallsGraph proc~test_cptr_wrapper test_cptr_wrapper assertfalse assertfalse proc~test_cptr_wrapper->assertfalse asserttrue asserttrue proc~test_cptr_wrapper->asserttrue interface~ut_free_system ut_free_system proc~test_cptr_wrapper->interface~ut_free_system none~get_cptr CptrWrapper%get_cptr proc~test_cptr_wrapper->none~get_cptr none~is_free CptrWrapper%is_free proc~test_cptr_wrapper->none~is_free

Source Code

   subroutine test_cptr_wrapper()
      type(UDSystem) :: wrapper
      type(c_ptr) :: cptr
      logical :: cassoc

      wrapper = UDSystem()
      cptr = wrapper%get_cptr()
      cassoc = c_associated(cptr)
      @assertTrue(cassoc, 'Did not get c_ptr')
      if(cassoc) then
         @assertFalse(wrapper%is_free(), 'c_ptr should be set.')
         call wrapper%free()
         cptr = wrapper%get_cptr()
         @assertFalse(c_associated(cptr), 'c_ptr should not be associated')
         @assertTrue(wrapper%is_free(), 'c_ptr should not be set')
      end if
      if(c_associated(cptr)) call ut_free_system(cptr)

   end subroutine test_cptr_wrapper