[pypy-commit] pypy reflex-support: copy constructor test
wlav
noreply at buildbot.pypy.org
Wed Mar 20 23:51:57 CET 2013
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r62588:f59f2e75c584
Date: 2013-03-20 14:59 -0700
http://bitbucket.org/pypy/pypy/changeset/f59f2e75c584/
Log: copy constructor test
diff --git a/pypy/module/cppyy/test/datatypes.h b/pypy/module/cppyy/test/datatypes.h
--- a/pypy/module/cppyy/test/datatypes.h
+++ b/pypy/module/cppyy/test/datatypes.h
@@ -11,6 +11,36 @@
//===========================================================================
enum fruit { kApple=78, kBanana=29, kCitrus=34 };
+
+//===========================================================================
+class four_vector {
+public:
+ four_vector(double x, double y, double z, double t) :
+ m_x(x), m_y(y), m_z(z), m_t(t), m_cc_called(false) {}
+ four_vector(const four_vector& s) :
+ m_x(s.m_x), m_y(s.m_y), m_z(s.m_z), m_t(s.m_t), m_cc_called(true) {}
+
+ double operator[](int i) {
+ if (i == 0) return m_x;
+ if (i == 1) return m_y;
+ if (i == 2) return m_z;
+ if (i == 3) return m_t;
+ return -1;
+ }
+
+ bool operator==(const four_vector& o) {
+ return (m_x == o.m_x && m_y == o.m_y &&
+ m_z == o.m_z && m_t == o.m_t);
+ }
+
+public:
+ bool m_cc_called;
+
+private:
+ double m_x, m_y, m_z, m_t;
+};
+
+
//===========================================================================
class cppyy_test_data {
public:
diff --git a/pypy/module/cppyy/test/datatypes.xml b/pypy/module/cppyy/test/datatypes.xml
--- a/pypy/module/cppyy/test/datatypes.xml
+++ b/pypy/module/cppyy/test/datatypes.xml
@@ -1,6 +1,7 @@
<lcgdict>
<class pattern="cppyy_test_*" />
+ <class name="four_vector" />
<enum name="fruit" />
diff --git a/pypy/module/cppyy/test/datatypes_LinkDef.h b/pypy/module/cppyy/test/datatypes_LinkDef.h
--- a/pypy/module/cppyy/test/datatypes_LinkDef.h
+++ b/pypy/module/cppyy/test/datatypes_LinkDef.h
@@ -6,6 +6,7 @@
#pragma link C++ struct cppyy_test_pod;
#pragma link C++ class cppyy_test_data;
+#pragma link C++ class four_vector;
#pragma link C++ enum fruit;
diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py
--- a/pypy/module/cppyy/test/test_datatypes.py
+++ b/pypy/module/cppyy/test/test_datatypes.py
@@ -459,7 +459,23 @@
assert gbl.kBanana == 29
assert gbl.kCitrus == 34
- def test12_object_returns(self):
+ def test12_copy_contructor(self):
+ """Test copy constructor"""
+
+ import cppyy
+ four_vector = cppyy.gbl.four_vector
+
+ t1 = four_vector(1., 2., 3., -4.)
+ t2 = four_vector(0., 0., 0., 0.)
+ t3 = four_vector(t1)
+
+ assert t1 == t3
+ assert t1 != t2
+
+ for i in range(4):
+ assert t1[i] == t3[i]
+
+ def test13_object_returns(self):
"""Test access to and return of PODs"""
import cppyy
@@ -486,7 +502,7 @@
assert c.get_pod_ptrref().m_int == 666
assert c.get_pod_ptrref().m_double == 3.14
- def test13_object_arguments(self):
+ def test14_object_arguments(self):
"""Test setting and returning of a POD through arguments"""
import cppyy
@@ -554,7 +570,7 @@
assert p.m_int == 888
assert p.m_double == 3.14
- def test14_respect_privacy(self):
+ def test15_respect_privacy(self):
"""Test that privacy settings are respected"""
import cppyy
@@ -567,7 +583,7 @@
c.destruct()
- def test15_buffer_reshaping(self):
+ def test16_buffer_reshaping(self):
"""Test usage of buffer sizing"""
import cppyy
More information about the pypy-commit
mailing list