- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have cobbled together a basic testing framework proof of concept to protect my projects agasint regressions as I update/rewrite portions of the codebase. What I have works, but is a bit tedious to setup and I am curious if there is a better way to implement this that I am overlooking.
The approach I have taken (code below) is to declare an abstract interface that contains generic function signatures that I'll need to call, then defined a function for each abstract interface that accepts the procedure and the arguments and perofms the test. Finally I have give access to the specific tests with a generic name. This approach will require an abstract interface and a function for each unique function signature in the code I wish to test and while I am willing to accept that, I want to make sure I'm not doing this in a sub-optimal way before I proceed. Any input is welcome.
Thanks.
[fortran]
module testing
implicit none
private
public :: test
interface test
module procedure test_ccioc
module procedure test_c
module procedure test_no_arg
end interface
abstract interface
integer function test_char_char_int_optchar(char1, char2, int1, ochar)
character(len=*), intent(in) :: char1, char2
integer, intent(in) :: int1
character, optional, intent(in) :: ochar
end function
integer function test_char(char1)
character(len=*), intent(in) :: char1
end function
integer function test_none()
end function
end interface
contains
integer function test_no_arg(test_name, expected_result, test_func) result(actual_result)
implicit none
character(len=*), intent(in) :: test_name
integer, intent(in) :: expected_result
procedure(test_none) :: test_func
call test_announce(test_name, expected_result)
actual_result = test_func()
call test_result(test_name, expected_result, actual_result)
end function
integer function test_c(test_name, expected_result, test_func, char1) result(actual_result)
implicit none
character(len=*), intent(in) :: test_name
integer, intent(in) :: expected_result
procedure(test_char) :: test_func
character(len=*), intent(in) :: char1
call test_announce(test_name, expected_result)
actual_result = test_func(char1)
call test_result(test_name, expected_result, actual_result)
end function
integer function test_ccioc(test_name, expected_result, test_func, char1, char2, int1, ochar) result(actual_result)
implicit none
character(len=*), intent(in) :: test_name
integer, intent(in) :: expected_result
procedure(test_char_char_int_optchar) :: test_func
character(len=*), intent(in) :: char1, char2
integer, intent(in) :: int1
character, optional, intent(in) :: ochar
call test_announce(test_name, expected_result)
actual_result = test_func(char1, char2, int1, ochar)
call test_result(test_name, expected_result, actual_result)
end function
...
end module testing
[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Casy,
Look at: http://sourceforge.net/apps/mediawiki/blockit/index.php?title=Main_Page
And and example of a template: http://sourceforge.net/apps/mediawiki/blockit/index.php?title=PyF95%2B%2B/Tutorials/Templated_Module_Tutorial
It is a way of using the scripting language PyF95 to write quazi-templates.
Jim Dempsey
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Casy,
Look at: http://sourceforge.net/apps/mediawiki/blockit/index.php?title=Main_Page
And and example of a template: http://sourceforge.net/apps/mediawiki/blockit/index.php?title=PyF95%2B%2B/Tutorials/Templated_Module_Tutorial
It is a way of using the scripting language PyF95 to write quazi-templates.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim,
Thanks for those links. I was contemplating writing a python script to parse my code and generate the unit testing interfaces, but it looks like this will save me the trouble.
-Casey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page