summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup.py2
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/regressextra.c51
-rw-r--r--tests/regressextra.h17
-rw-r--r--tests/test_everything.py31
5 files changed, 106 insertions, 3 deletions
diff --git a/setup.py b/setup.py
index 5d064914..b1563868 100755
--- a/setup.py
+++ b/setup.py
@@ -356,12 +356,14 @@ class build_tests(Command):
name='libregress',
sources=[
os.path.join(gi_tests_dir, "regress.c"),
+ os.path.join(tests_dir, "regressextra.c"),
],
include_dirs=[
gi_tests_dir,
],
depends=[
os.path.join(gi_tests_dir, "regress.h"),
+ os.path.join(tests_dir, "regressextra.h"),
],
)
add_ext_pkg_config_dep(ext, compiler.compiler_type, "glib-2.0")
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aef0528a..abb151d2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -53,12 +53,13 @@ GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile
test_ltlibraries += libregress.la
test_typelibs += Regress-1.0.typelib
nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
+dist_libregress_la_SOURCES = $(srcdir)/regressextra.c $(srcdir)/regressextra.h
# We don't control the source so don't pass WARN_CFLAGS etc
if ENABLE_CAIRO
-libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS)
+libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS) -I$(GI_DATADIR)/tests
libregress_la_LIBADD = $(GIO_LIBS) $(CAIRO_LIBS)
else
-libregress_la_CFLAGS = $(GIO_CFLAGS) -D_GI_DISABLE_CAIRO
+libregress_la_CFLAGS = $(GIO_CFLAGS) -D_GI_DISABLE_CAIRO -I$(GI_DATADIR)/tests
libregress_la_LIBADD = $(GIO_LIBS) $(CAIRO_LIBS)
endif
libregress_la_LDFLAGS = $(common_ldflags)
@@ -71,7 +72,8 @@ Regress-1.0.gir: libregress.la Makefile
--library=libregress.la \
--libtool="$(top_builddir)/libtool" \
--output $@ \
- $(nodist_libregress_la_SOURCES)
+ $(nodist_libregress_la_SOURCES) \
+ $(dist_libregress_la_SOURCES)
Regress-1.0.typelib: Regress-1.0.gir Makefile
$(AM_V_GEN) $(INTROSPECTION_COMPILER) $< -o $@
diff --git a/tests/regressextra.c b/tests/regressextra.c
new file mode 100644
index 00000000..4df4eddc
--- /dev/null
+++ b/tests/regressextra.c
@@ -0,0 +1,51 @@
+#include "regress.h"
+#include "regressextra.h"
+
+#include <glib-object.h>
+
+struct _RegressTestBoxedCWrapper
+{
+ RegressTestBoxedC * cptr;
+};
+
+RegressTestBoxedCWrapper *
+regress_test_boxed_c_wrapper_new (void)
+{
+ RegressTestBoxedCWrapper *boxed;
+ boxed = g_slice_new (RegressTestBoxedCWrapper);
+ boxed->cptr = regress_test_boxed_c_new ();
+ return boxed;
+}
+
+RegressTestBoxedCWrapper *
+regress_test_boxed_c_wrapper_copy (RegressTestBoxedCWrapper *self)
+{
+ RegressTestBoxedCWrapper *ret_boxed;
+ ret_boxed = g_slice_new (RegressTestBoxedCWrapper);
+ ret_boxed->cptr = g_boxed_copy (regress_test_boxed_c_get_type(), self->cptr);
+ return ret_boxed;
+}
+
+static void
+regress_test_boxed_c_wrapper_free (RegressTestBoxedCWrapper *boxed)
+{
+ g_boxed_free (regress_test_boxed_c_get_type(), boxed->cptr);
+ g_slice_free (RegressTestBoxedCWrapper, boxed);
+}
+
+G_DEFINE_BOXED_TYPE(RegressTestBoxedCWrapper,
+ regress_test_boxed_c_wrapper,
+ regress_test_boxed_c_wrapper_copy,
+ regress_test_boxed_c_wrapper_free);
+
+/**
+ * regress_test_boxed_c_wrapper_get
+ * @self: a #RegressTestBoxedCWrapper objects
+ *
+ * Returns: (transfer none): associated #RegressTestBoxedC
+**/
+RegressTestBoxedC *
+regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self)
+{
+ return self->cptr;
+}
diff --git a/tests/regressextra.h b/tests/regressextra.h
new file mode 100644
index 00000000..0753cddc
--- /dev/null
+++ b/tests/regressextra.h
@@ -0,0 +1,17 @@
+#ifndef REGRESS_EXTRA_H
+#define REGRESS_EXTRA_H
+
+typedef struct _RegressTestBoxedC RegressTestBoxedC;
+typedef struct _RegressTestBoxedCWrapper RegressTestBoxedCWrapper;
+
+_GI_TEST_EXTERN
+GType regress_test_boxed_c_wrapper_get_type (void);
+
+_GI_TEST_EXTERN
+RegressTestBoxedCWrapper *regress_test_boxed_c_wrapper_new (void);
+_GI_TEST_EXTERN
+RegressTestBoxedCWrapper * regress_test_boxed_c_wrapper_copy (RegressTestBoxedCWrapper *self);
+_GI_TEST_EXTERN
+RegressTestBoxedC *regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self);
+
+#endif /* REGRESS_EXTRA_H */
diff --git a/tests/test_everything.py b/tests/test_everything.py
index ac97e057..b7fcb2af 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -1129,6 +1129,37 @@ class TestBoxed(unittest.TestCase):
self.assertEqual(boxed, copy)
self.assertNotEqual(id(boxed), id(copy))
+ @unittest.expectedFailure
+ def test_boxed_c_wrapper(self):
+ wrapper = Everything.TestBoxedCWrapper()
+ obj = wrapper.get()
+
+ # TestBoxedC uses refcounting, so we know that
+ # it should be 2 at this point:
+ # - one owned by @wrapper
+ # - another owned by @obj
+ self.assertEqual(obj.refcount, 2)
+ del wrapper
+ self.assertEqual(obj.refcount, 1)
+
+ @unittest.expectedFailure
+ def test_boxed_c_wrapper_copy(self):
+ wrapper = Everything.TestBoxedCWrapper()
+ wrapper_copy = wrapper.copy()
+ obj = wrapper.get()
+
+ # TestBoxedC uses refcounting, so we know that
+ # it should be 3 at this point:
+ # - one owned by @wrapper
+ # - one owned by @wrapper_copy
+ # - another owned by @obj
+ self.assertEqual(obj.refcount, 3)
+ del wrapper
+ self.assertEqual(obj.refcount, 2)
+ del wrapper_copy
+ self.assertEqual(obj.refcount, 1)
+ del obj
+
class TestTortureProfile(unittest.TestCase):
def test_torture_profile(self):