-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Add R283 tests and modular functions for tests in Fortran and C.
- Loading branch information
1 parent
5f1df89
commit 968694e
Showing
5 changed files
with
135 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module test__common | ||
use iso_c_binding | ||
implicit none | ||
|
||
contains | ||
|
||
function roundn(x, n)result(r)bind(C) | ||
implicit none | ||
real(c_double), intent(in), value :: x | ||
integer(c_int), intent(in), value :: n | ||
real(c_double) :: r | ||
real(c_double) :: fac | ||
|
||
fac = 10**n | ||
r = nint(x*fac, kind=kind(x)) / fac | ||
|
||
end function | ||
|
||
function assertEqual(x1, x2, n)result(r)bind(C, name="assertEqual") | ||
implicit none | ||
real(c_double), intent(in), value :: x1 | ||
real(c_double), intent(in), value :: x2 | ||
integer(c_int), intent(in), value :: n | ||
logical(c_bool) :: r | ||
|
||
real(c_double) :: fac | ||
real(c_double) :: ix1 | ||
real(c_double) :: ix2 | ||
|
||
fac = 10**n | ||
ix1 = nint(x1 * fac, kind=kind(n)) | ||
ix2 = nint(x2 * fac, kind=kind(n)) | ||
r = ix1 == ix2 | ||
|
||
end function | ||
|
||
end module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef COMMON_H | ||
#define COMMON_H | ||
#include <stdbool.h> | ||
extern double roundn(double x, int n); | ||
extern bool assertEqual(double x1, double x2, int n); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters