Skip to content

Commit

Permalink
More coverage of FTValueDictionary
Browse files Browse the repository at this point in the history
Use routine missed in previous commit. fix bug in casting subroutine where the wrong pointer was nullified.
  • Loading branch information
DavidAKopriva committed May 27, 2023
1 parent d655c21 commit 5b0f9a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Source/FTObjects/FTValueDictionaryClass.f90
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ END FUNCTION stringValueForKey
SUBROUTINE castDictionaryToValueDictionary(dict,valueDict)
!
! -----------------------------------------------------
! Cast the base class FTObject to the FTException class
! Cast a FTDictionary to a FTValueDictionary as a
! subroutine call.
! -----------------------------------------------------
!
IMPLICIT NONE
Expand Down Expand Up @@ -405,7 +406,7 @@ SUBROUTINE castObjectToValueDictionary(obj,valueDict)
CLASS(FTValueDictionary), POINTER :: valueDict
CLASS(FTObject) , POINTER :: obj

obj => NULL()
valueDict => NULL()
SELECT TYPE (obj)
TYPE is (FTValueDictionary)
valueDict => obj
Expand All @@ -420,7 +421,8 @@ END SUBROUTINE castObjectToValueDictionary
FUNCTION valueDictionaryFromDictionary(dict) RESULT(valueDict)
!
! -----------------------------------------------------
! Cast the base class FTObject to the FTException class
! Cast FTDictionary to the FTValueDictionary class as
! a function call.
! -----------------------------------------------------
!
IMPLICIT NONE
Expand Down
9 changes: 8 additions & 1 deletion Testing/Tests/ValueDictionaryTests.f90
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,21 @@ SUBROUTINE FTValueDictionaryClassTests
valDict => valueDictionaryFromObject(obj)
CALL FTAssert(ASSOCIATED(valDict),msg = "Cast object to dictionary")

valDict => NULL()
CALL castObjectToValueDictionary(obj,valDict)
CALL FTAssert(ASSOCIATED(valDict),msg = "Cast object to dictionary by alternate")

valDict => NULL()
plainDict => dict3
CALL FTAssert(ASSOCIATED(plainDict),msg = "Cast object to dictionary")
CALL FTAssert(ASSOCIATED(plainDict),msg = "Point dictionary to value dictionary")

valDict => valueDictionaryFromDictionary(plainDict)
CALL FTAssert(ASSOCIATED(valDict),msg = "Cast dictionary to valuedictionary")
CALL FTAssert(valDict % containsKey(key = "name"),msg = "Test integrity of casting")

CALL castDictionaryToValueDictionary(plainDict,valDict)
CALL FTAssert(ASSOCIATED(valDict),msg = "Cast dictionary to valuedictionary as subroutine call ")
CALL FTAssert(valDict % containsKey(key = "name"),msg = "Test integrity of casting")

CALL releaseFTValueDictionary(dict3)
CALL FTAssert(.NOT.ASSOCIATED(dict3),msg = "Release dictionary should deallocate")
Expand Down

0 comments on commit 5b0f9a7

Please sign in to comment.