Skip to content

Commit

Permalink
Merge pull request #337 from esmf-org/fix/test-coverage
Browse files Browse the repository at this point in the history
Fix/test coverage
  • Loading branch information
theurich authored Dec 17, 2024
2 parents 7b5c03e + 8c9bd16 commit d9000f1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/Infrastructure/Base/tests/ESMF_InfoUTest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,29 @@ program ESMF_InfoUTest
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
!NEX_UTest
write(name, *) "ESMF_InfoLog"
write(failMsg, *) "Did not return success."

rc = ESMF_FAILURE

info6 = ESMF_InfoCreate(rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

call ESMF_InfoSet(info6, "/i/am/nested", 111, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

call ESMF_InfoSet(info6, "top-level", 222, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)

call ESMF_InfoLog(info6, prefix="info6: ", rc=rc)
call ESMF_Test((rc == ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

call ESMF_InfoDestroy(info6, rc=rc)
if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)
!----------------------------------------------------------------------------

!----------------------------------------------------------------------------
!NEX_UTest
write(name, *) "ESMF_InfoRemove Child From Parent"
Expand Down
4 changes: 2 additions & 2 deletions src/Infrastructure/Util/interface/ESMF_Util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ end function ESMF_UtilString2Real
!-----------------------------------------------------------------------------


!BOP
!BOPI
! !IROUTINE: ESMF_UtilStringDiffMatch - Match differences between two strings
! !INTERFACE:
function ESMF_UtilStringDiffMatch(string1, string2, minusStringList, &
Expand Down Expand Up @@ -1031,7 +1031,7 @@ function ESMF_UtilStringDiffMatch(string1, string2, minusStringList, &
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
!EOPI
!-----------------------------------------------------------------------------
! local variables
integer :: localrc
Expand Down
52 changes: 52 additions & 0 deletions src/Infrastructure/Util/tests/ESMF_UtilUTest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ program ESMF_UtilUTest
integer :: nargs
character(ESMF_MAXPATHLEN) :: program_path
integer :: argindex
logical :: matchFlag

real(ESMF_KIND_R8) :: random_values(50) = (/ &
0.997560, 0.566825, 0.965915, 0.747928, 0.367391, &
Expand Down Expand Up @@ -1006,6 +1007,57 @@ program ESMF_UtilUTest
! Internal string utilities (NOT part of the external ESMF API)
!==============================================================

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - identical strings - Test"
write(failMsg, *) "Did not return ESMF_SUCCESS"
matchFlag = ESMF_UtilStringDiffMatch( &
string1="A simple test string", string2="A simple test string", &
minusStringList=[""], plusStringList=[""], rc=rc)
call ESMF_Test((rc == ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - identical strings - match Test"
write(failMsg, *) "Did not return correct match flag"
call ESMF_Test(matchFlag, name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - different strings - Test"
write(failMsg, *) "Did not return ESMF_SUCCESS"
matchFlag = ESMF_UtilStringDiffMatch( &
string1="A simple test string", string2="A xyzzyx test string", &
minusStringList=[""], plusStringList=[""], rc=rc)
call ESMF_Test((rc == ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - different strings - match Test"
write(failMsg, *) "Did not return correct match flag"
call ESMF_Test(.not.matchFlag, name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - different strings minus/plus - Test"
write(failMsg, *) "Did not return ESMF_SUCCESS"
matchFlag = ESMF_UtilStringDiffMatch( &
string1="A simple test string", string2="A xyzzyx test string", &
minusStringList=["simple"], plusStringList=["xyzzyx"], rc=rc)
call ESMF_Test((rc == ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
write(name, *) "ESMF_UtilStringDiffMatch() - different strings minus/plus - match Test"
write(failMsg, *) "Did not return correct match flag"
call ESMF_Test(matchFlag, name, failMsg, result, ESMF_SRCLINE)
!------------------------------------------------------------------------

!------------------------------------------------------------------------
!EX_UTest
! Test concatenating strings
Expand Down

0 comments on commit d9000f1

Please sign in to comment.