Split C complex.h from C++ complex testing

This commit is contained in:
William S Fulton 2020-10-10 09:11:43 +01:00
commit fd592fdc3b
7 changed files with 117 additions and 98 deletions

View file

@ -83,19 +83,13 @@ CPP11_TEST_CASES = \
cpp11_std_unordered_set \
C_TEST_CASES += \
complextest \
ccomplextest \
file_test \
li_cstring \
li_cwstring \
python_nondynamic \
python_varargs_typemap \
#
# This test only works with modern C compilers
#
#C_TEST_CASES += \
# complextest
include $(srcdir)/../common.mk
# Overridden variables here

View file

@ -0,0 +1,24 @@
import ccomplextest
a = complex(-1, 2)
if ccomplextest.has_c99_complex():
if ccomplextest.Conj(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if ccomplextest.Conjf(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if ccomplextest.Conj2(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if ccomplextest.Conjf2(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if ccomplextest.Conj3(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if ccomplextest.Conjf3(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
else:
print("Not a c99 compiler")

View file

@ -14,26 +14,16 @@ if complextest.Conj2(a) != a.conjugate():
if complextest.Conjf2(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if 'Conj3' in dir(complextest):
if complextest.Conj3(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
if 'Conjf3' in dir(complextest):
if complextest.Conjf3(a) != a.conjugate():
raise RuntimeError("bad complex mapping")
if len(complextest.CopyHalf(v)) != 2:
raise RuntimeError("CopyHalf failed")
if 'CopyHalf' in dir(complextest):
if len(complextest.CopyHalfRef(v)) != 2:
raise RuntimeError("CopyHalfRef failed")
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
if len(complextest.CopyHalf(v)) != 2:
raise RuntimeError("CopyHalf failed")
if len(complextest.CopyHalfRef(v)) != 2:
raise RuntimeError("CopyHalfRef failed")
p = complextest.ComplexPair()
p.z1 = complex(0, 1)
p.z2 = complex(0, -1)
if complextest.Conj(p.z2) != p.z1:
raise RuntimeError("bad complex mapping")
p = complextest.ComplexPair()
p.z1 = complex(0, 1)
p.z2 = complex(0, -1)
if complextest.Conj(p.z2) != p.z1:
raise RuntimeError("bad complex mapping")