[pygobject/685197: 4/4] tests: check passing Boxed type in GValue as function parameters



commit d3311da956a67b5fbc5d63533a4b0820c3ed48a9
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Feb 5 15:00:10 2016 +0100

    tests: check passing Boxed type in GValue as function parameters
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761592

 tests/Makefile.am               |   13 +++++++++++--
 tests/gimarshallingtestsextra.c |   37 +++++++++++++++++++++++++++++++++++++
 tests/gimarshallingtestsextra.h |   26 ++++++++++++++++++++++++++
 tests/test_error.py             |    6 ++++++
 4 files changed, 80 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9d5db5e..233175c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,14 @@ CLEANFILES =
 check_LTLIBRARIES = libgimarshallingtests.la
 test_typelibs = GIMarshallingTests-1.0.typelib
 
-nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c 
$(GI_DATADIR)/tests/gimarshallingtests.h
+nodist_libgimarshallingtests_la_SOURCES = \
+       $(GI_DATADIR)/tests/gimarshallingtests.c \
+       $(GI_DATADIR)/tests/gimarshallingtests.h
+
+dist_libgimarshallingtests_la_SOURCES = \
+       $(srcdir)/gimarshallingtestsextra.c \
+       $(srcdir)/gimarshallingtestsextra.h
+
 libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS)
 libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) -no-undefined
 
@@ -17,7 +24,9 @@ GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile
        --library=libgimarshallingtests.la \
        --libtool="$(top_builddir)/libtool" \
        --output $@ \
-       $(nodist_libgimarshallingtests_la_SOURCES)
+       $(nodist_libgimarshallingtests_la_SOURCES) \
+       $(dist_libgimarshallingtests_la_SOURCES)
+
 GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile
        $(AM_V_GEN) g-ir-compiler $< -o $@
 
diff --git a/tests/gimarshallingtestsextra.c b/tests/gimarshallingtestsextra.c
new file mode 100644
index 0000000..9624077
--- /dev/null
+++ b/tests/gimarshallingtestsextra.c
@@ -0,0 +1,37 @@
+/* gimarshallingtestsextra.c
+ *
+ * Copyright (C) 2016 Thibault Saunier <tsaunier gnome org>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gimarshallingtestsextra.h"
+
+void
+gi_marshalling_tests_compare_two_gerrors_in_gvalue (GValue *v, GValue *v1)
+{
+  GError *error, * error1;
+
+  g_assert_cmpstr (g_type_name (G_VALUE_TYPE (v)), ==,
+                   g_type_name (G_TYPE_ERROR));
+  g_assert_cmpstr (g_type_name (G_VALUE_TYPE (v1)), ==,
+                   g_type_name (G_TYPE_ERROR));
+
+  error = (GError*) g_value_get_boxed (v);
+  error1 = (GError*) g_value_get_boxed (v1);
+
+  g_assert_cmpint (error->domain, ==, error1->domain);
+  g_assert_cmpint (error->code, ==, error1->code);
+  g_assert_cmpstr (error->message, ==, error1->message);
+}
diff --git a/tests/gimarshallingtestsextra.h b/tests/gimarshallingtestsextra.h
new file mode 100644
index 0000000..6858551
--- /dev/null
+++ b/tests/gimarshallingtestsextra.h
@@ -0,0 +1,26 @@
+/* gimarshallingtestsextra.h
+ *
+ * Copyright (C) 2016 Thibault Saunier <tsaunier gnome org>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EXTRA_TESTS
+#define EXTRA_TESTS
+
+#include <glib-object.h>
+
+void gi_marshalling_tests_compare_two_gerrors_in_gvalue (GValue *v, GValue *v1);
+
+#endif /* EXTRA_TESTS */
diff --git a/tests/test_error.py b/tests/test_error.py
index f5a89ce..5702490 100644
--- a/tests/test_error.py
+++ b/tests/test_error.py
@@ -133,6 +133,12 @@ class TestMarshalling(unittest.TestCase):
         self.assertEqual(e.domain, 'mydomain')
         self.assertEqual(e.code, 42)
 
+    def tests_compare_two_gerrors_in_gvalue(self):
+        error = GLib.Error.new_literal(1, "error", 1)
+        error1 = GLib.Error.new_literal(1, "error", 1)
+
+        GIMarshallingTests.compare_two_gerrors_in_gvalue(error, error1)
+
 
 if __name__ == '__main__':
     unittest.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]