I know the idea of private variables is that they shouldn't be accessed, and I do want it to work this way when using the module in the rest of the program, but I need it for the purpose of checking the internal workings of the module.
Say I have the following simplified example:
module mod
implicit none
private
integer :: value
public :: set_value
contains
subroutine set_value(input)
implicit none
integer,intent(in) :: input
value=input
end subroutine
end module
And I now want to test the subroutine to see if it is actually doing what I want: I would like to write a program that uses the module, calls the routine set_value
with input 8 and then checks if the internal variable value
is now 8.
Can I do this? Or is it there another way to unit test initializers of private variables?