C Library Functions  - unit_test_expected (3)

NAME

unit_test_expected(3f) - [M_framework__verify] report if two scalar values of like type and kind are equal. (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Examples
Author
License

SYNOPSIS

impure elemental subroutine unit_test_example(name,result,expected)

    character(len=*),intent(in)  :: name
    class(*),intent(in)          :: result
    class(*),intent(in),optional :: expected

DESCRIPTION

A shortcut for a common call to unit_test(3f) tests the two values of like type and kind. It is equivalent to

       call unit_test(name,result,expected,’result=’,result,’expected=’,.true.)

OPTIONS

RESULT A generated value or expression of integer, real, character, or complex type.
EXPECTED
  The expected value for RESULT, of the same type and kind as RESULT. If not present, it is equivalent to .TRUE.

EXAMPLES

Sample program:

      program demo_unit_test_expected
      use, intrinsic :: iso_fortran_env, only: &
      & stdin => input_unit, stdout => output_unit, stderr => error_unit
      use M_framework, only:                &
      &  unit_test_mode,                    &
      &  start     =>  unit_test_start,     &
      &  expected  =>  unit_test_expected,  &
      &  stop      =>  unit_test_stop,      &
      & unit_test_level, unit_test_flags
      implicit none
      logical, parameter :: T=.true., F=.false.
      ! optional call to change default modes
         call unit_test_mode(  &
             keep_going=T,     &
             flags=[0],        &
             luns=[stderr],    &
             command=’’,       &
             brief=F,          &
             match=’’,         &
             interactive=F,    &
             CMDLINE=T,        &
             debug=F)

unit_test_level=0 ! unit tests for ABS(3f) intrinsic call start(’abs’) ! integer call expected(’abs’,abs(-10),10) call expected(’abs’,abs( 10),10) ! real and elemental call expected(’abs’,abs( [-10.0, 10.0]),10.0) ! complex call expected(’abs’,abs(( 3.0,-4.0)),5.0) call expected(’abs’,abs((-3.0, 4.0)),5.0) call expected(’abs’,abs((-3.0,-4.0)),5.0) call expected(’abs’,abs(( 3.0, 4.0)),5.0) call stop(’abs’) end program demo_unit_test_expected

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 unit_test_expected (3) July 22, 2023
Generated by manServer 1.08 from b9e95bcf-6a2c-447f-9913-3ff25f8b008e using man macros.