2018-12-13 22:09:42 +00:00
|
|
|
/*
|
|
|
|
Unless explicitly stated otherwise all files in this repository are licensed
|
2021-08-05 10:47:52 +00:00
|
|
|
under the MIT License.
|
2018-12-13 22:09:42 +00:00
|
|
|
This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
|
|
Copyright 2018 Datadog, Inc.
|
|
|
|
*/
|
|
|
|
|
2018-12-06 17:24:59 +00:00
|
|
|
package python3
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestComplex(t *testing.T) {
|
2019-01-18 19:50:08 +00:00
|
|
|
Py_Initialize()
|
|
|
|
|
2018-12-06 17:24:59 +00:00
|
|
|
real := 2.
|
|
|
|
imaginary := 5.
|
|
|
|
|
|
|
|
complex := PyComplex_FromDoubles(real, imaginary)
|
|
|
|
assert.True(t, PyComplex_Check(complex))
|
|
|
|
assert.True(t, PyComplex_CheckExact(complex))
|
|
|
|
defer complex.DecRef()
|
|
|
|
|
|
|
|
assert.Equal(t, real, PyComplex_RealAsDouble(complex))
|
|
|
|
assert.Equal(t, imaginary, PyComplex_ImagAsDouble(complex))
|
|
|
|
}
|