Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: print progress #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/tester.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module tester
contains
procedure :: init !< Initialize the tester.
procedure :: print !< Print tests results.
procedure :: print_progress !< Print partial test results.
generic, public :: assert_equal => &
assert_equal_i8, &
assert_equal_i16, &
Expand Down Expand Up @@ -157,6 +158,18 @@ subroutine print(this, errorstop)

end subroutine print


!> Print partial information on tests results. Useful to track down where a probleb occurred.
subroutine print_progress(this, label)
class(tester_t), intent(in) :: this !< The tester.
character(len=*), intent(in) :: label !< Label representing current state.


write(*,*) 'fortran_tester: test "', label, '" completed.'
write(*,*) ' Currently ', this% n_errors, ' error(s) for', this% n_tests, 'test(s)'

end subroutine print_progress

!> Check if two integers (8 bits) are equal.
subroutine assert_equal_i8(this, i1, i2, fail)
class(tester_t), intent(inout) :: this !< The tester.
Expand Down
4 changes: 4 additions & 0 deletions test/test_tester_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ program test_tester_1

call test% assert_equal(.true., 2 > 1)

call test% print_progress("assert_equal")

call test% assert_close(1.d0, (1.d0+1.d-16))

call test% assert_close(1.d0, (1.d0+1.d-15), fail=.true.)
Expand All @@ -31,6 +33,8 @@ program test_tester_1
call test% assert_close([1.d0, 2.d0], [1.d0, 2.d0, 3.d0], fail=.true.)

call test% assert_close([1.d0, 2.d0], [1.d0, 2.d0])

call test% print_progress("assert_close")

call test% print()

Expand Down