Skip to content

Commit

Permalink
calculate value
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Sep 7, 2024
1 parent 7874fb1 commit cc36809
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import math

from ctypes import *

import pytest

def test_roszman1():

lib = CDLL('./Roszman1_x64.so')

buffer = create_string_buffer(256)
lib.GetFunctionName(buffer)
assert buffer.value == "f1: Roszman1 f1=a1-a2*x-arctan(a3/(x-a4))/pi"
assert buffer.value.decode() == "f1: Roszman1 f1=a1-a2*x-arctan(a3/(x-a4))/pi"

num = c_int()
lib.GetNumParameters(byref(num))
assert num.value == 3
assert num.value == 4

lib.GetNumVariables(byref(num))
assert num.value == 2
assert num.value == 1

x = -4868.68
a1, a2, a3, a4 = (0.2, -6e-6, 1.2e3, -1.8e2)
x_c = c_double(x)
a = (c_double * 4)(a1, a2, a3, a4)
y = c_double()
lib.GetFunctionValue(byref(x_c), byref(a), byref(y))
assert y.value == a1-a2*x-math.arctan(a3/(x-a4))/math.pi

0 comments on commit cc36809

Please # to comment.