test_print Subroutine

public subroutine test_print(test_name, message, test_pass)

Print the result of a test to the terminal

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: test_name

Name of the test being run

character(len=*), intent(in) :: message

Message to print

logical, intent(in) :: test_pass

Result of the assertion


Source Code

    subroutine test_print(test_name, message, test_pass)

      character(len=*), intent(in) :: test_name !! Name of the test being run
      character(len=*), intent(in) :: message !! Message to print
      logical, intent(in) :: test_pass !! Result of the assertion

      character(len=15) :: report

      if (test_pass) then
        report = char(27)//'[32m'//'PASSED'//char(27)//'[0m'
      else
        report = char(27)//'[31m'//'FAILED'//char(27)//'[0m'
      end if
      write(*, '(A, " :: [", A, "] ", A)') report, trim(test_name), trim(message)
    end subroutine test_print