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()


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 assertEqualTwoIntegerArrays1D(expectedValue, actualValue)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), DIMENSION(:) :: expectedValue
    integer, intent(in), DIMENSION(:) :: actualValue
  • private subroutine assertEqualTwoIntegerArrays2D(expectedValue, actualValue)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), DIMENSION(:,:) :: expectedValue
    integer, intent(in), DIMENSION(:,:) :: actualValue
  • private subroutine assertWithinToleranceTwoReal(expectedValue, actualValue, tol, msg)

    Arguments

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

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), DIMENSION(:) :: expectedValue
    real, intent(in), DIMENSION(:) :: actualValue
    real, intent(in) :: tol
    character(len=*), optional :: msg
  • private subroutine assertWithinToleranceTwoRealArrays2D(expectedValue, actualValue, tol)

    Arguments

    Type IntentOptional Attributes Name
    real, intent(in), DIMENSION(:,:) :: expectedValue
    real, intent(in), DIMENSION(:,:) :: actualValue
    real, intent(in) :: tol
  • private subroutine assertWithinToleranceTwoDouble(expectedValue, actualValue, tol, msg)

    Arguments

    Type IntentOptional Attributes Name
    double precision, intent(in) :: expectedValue
    double precision, intent(in) :: actualValue
    double precision, intent(in) :: tol
    character(len=*), optional :: msg
  • private subroutine assertWithinToleranceTwoDoubleArrays1D(expectedValue, actualValue, tol, msg)

    Arguments

    Type IntentOptional Attributes Name
    double precision, intent(in), DIMENSION(:) :: expectedValue
    double precision, intent(in), DIMENSION(:) :: actualValue
    double precision, intent(in) :: tol
    character(len=*), optional :: msg
  • private subroutine assertWithinToleranceTwoDoubleArrays2D(expectedValue, actualValue, tol)

    Arguments

    Type IntentOptional Attributes Name
    double precision, intent(in), DIMENSION(:,:) :: expectedValue
    double precision, intent(in), DIMENSION(:,:) :: actualValue
    double precision, intent(in) :: tol
  • public subroutine assertWithinToleranceTwoQuad(expectedValue, actualValue, tol, 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) :: tol
    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


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, tol, 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) :: tol
character(len=*), optional :: msg