FTAssertions Module

Assertions are functions that return true or false that can be placed in a program to test whether a predicate is true.

To use the assertions module, it must be initialized, usually in the main program. When it is no longer needed, it is finalized. Assertions are posted to the module as they are called, and can be summarized later at an appropriate time.

Initialization

  CALL initializeSharedAssertionsManager

Finalization

  CALL finalizeSharedAssertionsManager

Asserting

  CALL FTAssertEqual(expectedValue,resultValue,message)

Summarizing Assertions

  CALL SummarizeFTAssertions(title,unit)

Additional enquiry functions

  INTEGER :: nf, nA
   nF = numberOfAssertionFailures()
   nA = numberOfAssertions()

Uses

  • module~~ftassertions~~UsesGraph module~ftassertions FTAssertions iso_fortran_env iso_fortran_env module~ftassertions->iso_fortran_env module~comparisonsmodule ComparisonsModule module~ftassertions->module~comparisonsmodule module~ftolconstants FTOLConstants module~ftassertions->module~ftolconstants module~comparisonsmodule->iso_fortran_env module~comparisonsmodule->module~ftolconstants

Used by

  • module~~ftassertions~~UsedByGraph module~ftassertions FTAssertions module~ftobjectlibrary FTObjectLibrary module~ftobjectlibrary->module~ftassertions

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: FT_ASSERTION_STRING_LENGTH = 128

Interfaces

public interface FTAssertEqual

  • private subroutine assertEqualTwoIntegers(expectedValue, actualValue, msg)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: expectedValue
    integer, intent(in) :: actualValue
    character(len=*), optional :: msg
  • private subroutine assertWithinToleranceTwoReal(expectedValue, actualValue, relTol, absTol, msg)

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in) :: expectedValue
    real, intent(in) :: actualValue
    real, intent(in) :: relTol
    real, intent(in), optional :: absTol
    character(len=*), optional :: msg
  • private subroutine assertWithinToleranceTwoDouble(expectedValue, actualValue, relTol, absTol, msg)

    Arguments

    Type IntentOptional Attributes Name
    double precision, intent(in) :: expectedValue
    double precision, intent(in) :: actualValue
    double precision, intent(in) :: relTol
    double precision, intent(in), optional :: absTol
    character(len=*), optional :: msg
  • public subroutine assertWithinToleranceTwoQuad(expectedValue, actualValue, relTol, absTol, msg)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: expectedValue
    real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: actualValue
    real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: relTol
    real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in), optional :: absTol
    character(len=*), optional :: msg
  • private subroutine assertEqualTwoLogicals(expectedValue, actualValue, msg)

    Arguments

    Type IntentOptional Attributes Name
    logical, intent(in) :: expectedValue
    logical, intent(in) :: actualValue
    character(len=*), optional :: msg
  • private subroutine assertEqualString(expectedValue, actualValue, msg)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*) :: expectedValue
    character(len=*) :: actualValue
    character(len=*), optional :: msg

Derived Types

type, public ::  FTAssertionsManager

Type-Bound Procedures

procedure, public :: init
procedure, public :: finalize
procedure, public :: numberOfAssertionFailures
procedure, public :: numberOfAssertions
procedure, public :: summarizeAssertions

Functions

public function sharedAssertionsManager()

Arguments

None

Return Value type(FTAssertionsManager), POINTER

public function numberOfAssertions(self)

Arguments

Type IntentOptional Attributes Name
class(FTAssertionsManager) :: self

Return Value integer

public function numberOfAssertionFailures(self)

Arguments

Type IntentOptional Attributes Name
class(FTAssertionsManager) :: self

Return Value integer

public function SelfTestAssertion(assertionNumber, assertionType, expected, actual, msg)

Arguments

Type IntentOptional Attributes Name
integer :: assertionNumber
character(len=*) :: assertionType
character(len=*) :: expected
character(len=*) :: actual
character(len=*) :: msg

Return Value integer


Subroutines

public subroutine detachSharedAssertionsManager()

Arguments

None

public subroutine initializeSharedAssertionsManager()

Arguments

None

public subroutine finalizeSharedAssertionsManager()

Arguments

None

public subroutine FTAssert(test, msg)

Arguments

Type IntentOptional Attributes Name
logical :: test
character(len=*), optional :: msg

public subroutine assertWithinToleranceTwoQuad(expectedValue, actualValue, relTol, absTol, msg)

Arguments

Type IntentOptional Attributes Name
real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: expectedValue
real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: actualValue
real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in) :: relTol
real(kind=SELECTED_REAL_KIND(QUAD_DIGITS)), intent(in), optional :: absTol
character(len=*), optional :: msg