2022-01-09 18:53:36 +01:00
|
|
|
from ctypes import *
|
2022-02-16 08:12:49 +01:00
|
|
|
import math, os
|
2022-01-10 08:11:54 +01:00
|
|
|
|
2022-01-09 18:53:36 +01:00
|
|
|
so_file="./test.so"
|
2022-01-10 08:11:54 +01:00
|
|
|
if os.name=="nt":
|
|
|
|
so_file="./test.dll"
|
2022-02-16 08:12:49 +01:00
|
|
|
lib = CDLL(so_file)
|
|
|
|
assert lib.square(10) == 100, "Cannot validate V square()."
|
|
|
|
|
|
|
|
lib.sqrt_of_sum_of_squares.restype = c_double
|
|
|
|
assert lib.sqrt_of_sum_of_squares(c_double(1.1), c_double(2.2)) == math.sqrt(1.1*1.1 + 2.2*2.2), "Cannot validate V sqrt_of_sum_of_squares()."
|