2022-01-09 20:53:36 +03:00
|
|
|
from ctypes import *
|
2022-02-16 10:12:49 +03:00
|
|
|
import math, os
|
2022-01-10 10:11:54 +03:00
|
|
|
|
2022-01-09 20:53:36 +03:00
|
|
|
so_file="./test.so"
|
2022-01-10 10:11:54 +03:00
|
|
|
if os.name=="nt":
|
|
|
|
so_file="./test.dll"
|
2022-02-16 10:12:49 +03:00
|
|
|
lib = CDLL(so_file)
|
2022-10-16 22:48:00 +03:00
|
|
|
print("lib.square(10) result is", lib.square(10))
|
2022-02-16 10:12:49 +03:00
|
|
|
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()."
|