Skip to content

Commit

Permalink
Add fp32 test for custom function
Browse files Browse the repository at this point in the history
* Sole purpose is to increase code coverage here
  • Loading branch information
fluidnumerics-joe committed Jun 12, 2024
1 parent f166899 commit 17c0799
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ add_fortran_tests (
"tan_sfp32.f90"
"tan_sfp64.f90"
"print_tokens.f90"
"custom_r1fp32.f90"
"custom_r1fp64.f90"
"parsing_difficult_r1fp64.f90"
"parsing_vanderpol_sfp64.f90")
Expand Down
33 changes: 33 additions & 0 deletions test/custom_r1fp32.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
program test
use iso_fortran_env,only:i1 => int8,i2 => int16,i4 => int32,i8 => int64, &
r4 => real32,r8 => real64,r16 => real128
use FEQParse

implicit none

write(*,'(A,I20)') "test ",testing()

contains

integer function testing() result(r)
!private
type(EquationParser) :: f
real(r4) :: feval

call AddFunction("myfunc",myfunc32)

f = EquationParser("MYFUNC(x)",["x"])

feval = f%evaluate([1.0_r4])
if((abs(feval-0.5_r4)) <= epsilon(1.0_r4)) then
r = 0
else
r = 1
endif
endfunction

pure real(r4) function myfunc32(x)
real(r4),intent(in) :: x
myfunc32 = x/2.0_r4
endfunction
endprogram

0 comments on commit 17c0799

Please sign in to comment.