[gobject-introspection] tests: Add tests for various struct typedef combinations
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] tests: Add tests for various struct typedef combinations
- Date: Thu, 2 Jan 2014 22:42:58 +0000 (UTC)
commit 4a64ab0b8e3e6cf0ebb4f34dd9276e964e1f303c
Author: Simon Feltman <sfeltman src gnome org>
Date: Tue Dec 17 05:22:39 2013 -0800
tests: Add tests for various struct typedef combinations
Add functional blackbox tests typedefs.[h|c] for various struct typedef
orderings. Use XFAIL_TESTS with the new Typedefs-1.0.gir target.
This allows for a differing expected gir that does not cause the suite
to fail but rather a goal to work towards.
https://bugzilla.gnome.org/show_bug.cgi?id=581525
tests/scanner/Makefile.am | 11 ++++
tests/scanner/Typedefs-1.0-expected.gir | 84 ++++++++++++++++++++++++++++
tests/scanner/typedefs.c | 90 +++++++++++++++++++++++++++++++
tests/scanner/typedefs.h | 73 +++++++++++++++++++++++++
4 files changed, 258 insertions(+), 0 deletions(-)
---
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index a3f9a27..d72d255 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -16,6 +16,7 @@ EXTRA_LTLIBRARIES = \
libgettype.la \
libregress.la \
libwarnlib.la \
+ libtypedefs.la \
$(NULL)
CLEANFILES += $(EXTRA_LTLIBRARIES)
@@ -51,6 +52,7 @@ libwarnlib_la_SOURCES = $(srcdir)/warnlib.c $(srcdir)/warnlib.h
libwarnlib_la_LIBADD = $(GIO_LIBS)
libwarnlib_la_LDFLAGS = -export-symbols-regex '^warnlib_' -no-undefined
libgettype_la_SOURCES = $(srcdir)/gettype.c $(srcdir)/gettype.h
+libtypedefs_la_SOURCES = $(srcdir)/typedefs.c $(srcdir)/typedefs.h
testsdir = $(datadir)/gobject-introspection-1.0/tests
tests_DATA = $(libregress_la_SOURCES) $(libwarnlib_la_SOURCES) $(libutility_la_SOURCES)
@@ -130,6 +132,14 @@ GetType_1_0_gir_FILES = $(libgettype_la_SOURCES)
GetType_1_0_gir_SCANNERFLAGS = --c-include="gettype.h" --identifier-prefix=GetType --symbol-prefix=gettype
GIRS += GetType-1.0.gir
+Typedefs-1.0.gir: libtypedefs.la
+Typedefs_1_0_gir_PACKAGES = gobject-2.0
+Typedefs_1_0_gir_LIBS = libtypedefs.la
+Typedefs_1_0_gir_INCLUDES = GObject-2.0
+Typedefs_1_0_gir_FILES = $(libtypedefs_la_SOURCES)
+Typedefs_1_0_gir_SCANNERFLAGS = --c-include="typedefs.h" --identifier-prefix=Typedefs
--symbol-prefix=typedefs
+GIRS += Typedefs-1.0.gir
+
if !OS_WIN32
EXTRA_PROGRAMS = barapp
CLEANFILES += $(EXTRA_PROGRAMS)
@@ -182,6 +192,7 @@ else
CHECKDOCS =
endif
+XFAIL_TESTS = Typedefs-1.0.gir
TESTS = Headeronly-1.0.gir $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS)
TESTS_ENVIRONMENT = srcdir=$(srcdir) top_srcdir=$(top_srcdir) builddir=$(builddir)
top_builddir=$(top_builddir) \
$(top_srcdir)/tests/gi-tester
diff --git a/tests/scanner/Typedefs-1.0-expected.gir b/tests/scanner/Typedefs-1.0-expected.gir
new file mode 100644
index 0000000..9bfd0d0
--- /dev/null
+++ b/tests/scanner/Typedefs-1.0-expected.gir
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!-- This file was automatically generated from C sources - DO NOT EDIT!
+To affect the contents of this file, edit the original C definitions,
+and/or use gtk-doc annotations. -->
+<repository version="1.2"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+ <include name="GObject" version="2.0"/>
+ <package name="gobject-2.0"/>
+ <c:include name="typedefs.h"/>
+ <namespace name="Typedefs"
+ version="1.0"
+ shared-library="libtypedefs.so"
+ c:identifier-prefixes="Typedefs"
+ c:symbol-prefixes="typedefs">
+ <record name="BoxedWithAnonymousTypedef"
+ c:type="TypedefsBoxedWithAnonymousTypedef"
+ glib:type-name="TypedefsBoxedWithAnonymousTypedef"
+ glib:get-type="typedefs_boxed_with_anonymous_typedef_get_type"
+ c:symbol-prefix="boxed_with_anonymous_typedef">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="BoxedWithHiddenStruct"
+ c:type="TypedefsBoxedWithHiddenStruct"
+ glib:type-name="TypedefsBoxedWithHiddenStruct"
+ glib:get-type="typedefs_boxed_with_hidden_struct_get_type"
+ c:symbol-prefix="boxed_with_hidden_struct">
+ </record>
+ <record name="BoxedWithTagAndTypedef"
+ c:type="TypedefsBoxedWithTagAndTypedef"
+ glib:type-name="TypedefsBoxedWithTagAndTypedef"
+ glib:get-type="typedefs_boxed_with_tag_and_typedef_get_type"
+ c:symbol-prefix="boxed_with_tag_and_typedef">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="BoxedWithTypedefAfter"
+ c:type="TypedefsBoxedWithTypedefAfter"
+ glib:type-name="TypedefsBoxedWithTypedefAfter"
+ glib:get-type="typedefs_boxed_with_typedef_after_get_type"
+ c:symbol-prefix="boxed_with_typedef_after">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="BoxedWithTypedefBefore"
+ c:type="TypedefsBoxedWithTypedefBefore"
+ glib:type-name="TypedefsBoxedWithTypedefBefore"
+ glib:get-type="typedefs_boxed_with_typedef_before_get_type"
+ c:symbol-prefix="boxed_with_typedef_before">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="StructWithAnonymousTypedef"
+ c:type="TypedefsStructWithAnonymousTypedef">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="StructWithTagAndTypedef"
+ c:type="TypedefsStructWithTagAndTypedef">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="StructWithTypedefAfter"
+ c:type="TypedefsStructWithTypedefAfter">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ <record name="StructWithTypedefBefore"
+ c:type="TypedefsStructWithTypedefBefore">
+ <field name="value" writable="1">
+ <type name="gint" c:type="int"/>
+ </field>
+ </record>
+ </namespace>
+</repository>
diff --git a/tests/scanner/typedefs.c b/tests/scanner/typedefs.c
new file mode 100644
index 0000000..7c1dea1
--- /dev/null
+++ b/tests/scanner/typedefs.c
@@ -0,0 +1,90 @@
+#include "typedefs.h"
+
+static TypedefsBoxedWithTypedefBefore *
+typedefs_boxed_with_typedef_before_ref(TypedefsBoxedWithTypedefBefore *self)
+{
+ return self;
+}
+
+static void
+typedefs_boxed_with_typedef_before_unref(TypedefsBoxedWithTypedefBefore *self)
+{
+}
+
+G_DEFINE_BOXED_TYPE (TypedefsBoxedWithTypedefBefore,
+ typedefs_boxed_with_typedef_before,
+ typedefs_boxed_with_typedef_before_ref,
+ typedefs_boxed_with_typedef_before_unref);
+
+
+static TypedefsBoxedWithTypedefAfter *
+typedefs_boxed_with_typedef_after_ref(TypedefsBoxedWithTypedefAfter *self)
+{
+ return self;
+}
+
+static void
+typedefs_boxed_with_typedef_after_unref(TypedefsBoxedWithTypedefAfter *self)
+{
+}
+
+G_DEFINE_BOXED_TYPE (TypedefsBoxedWithTypedefAfter,
+ typedefs_boxed_with_typedef_after,
+ typedefs_boxed_with_typedef_after_ref,
+ typedefs_boxed_with_typedef_after_unref);
+
+
+static TypedefsBoxedWithTagAndTypedef *
+typedefs_boxed_with_tag_and_typedef_ref(TypedefsBoxedWithTagAndTypedef *self)
+{
+ return self;
+}
+
+static void
+typedefs_boxed_with_tag_and_typedef_unref(TypedefsBoxedWithTagAndTypedef *self)
+{
+}
+
+G_DEFINE_BOXED_TYPE (TypedefsBoxedWithTagAndTypedef,
+ typedefs_boxed_with_tag_and_typedef,
+ typedefs_boxed_with_tag_and_typedef_ref,
+ typedefs_boxed_with_tag_and_typedef_unref);
+
+
+static TypedefsBoxedWithAnonymousTypedef *
+typedefs_boxed_with_anonymous_typedef_ref(TypedefsBoxedWithAnonymousTypedef *self)
+{
+ return self;
+}
+
+static void
+typedefs_boxed_with_anonymous_typedef_unref(TypedefsBoxedWithAnonymousTypedef *self)
+{
+}
+
+G_DEFINE_BOXED_TYPE (TypedefsBoxedWithAnonymousTypedef,
+ typedefs_boxed_with_anonymous_typedef,
+ typedefs_boxed_with_anonymous_typedef_ref,
+ typedefs_boxed_with_anonymous_typedef_unref);
+
+
+struct _TypedefsBoxedWithHiddenStruct {
+ int value;
+};
+
+static TypedefsBoxedWithHiddenStruct *
+typedefs_boxed_with_hidden_struct_ref(TypedefsBoxedWithHiddenStruct *self)
+{
+ return self;
+}
+
+static void
+typedefs_boxed_with_hidden_struct_unref(TypedefsBoxedWithHiddenStruct *self)
+{
+}
+
+G_DEFINE_BOXED_TYPE (TypedefsBoxedWithHiddenStruct,
+ typedefs_boxed_with_hidden_struct,
+ typedefs_boxed_with_hidden_struct_ref,
+ typedefs_boxed_with_hidden_struct_unref);
+
diff --git a/tests/scanner/typedefs.h b/tests/scanner/typedefs.h
new file mode 100644
index 0000000..2a5d8be
--- /dev/null
+++ b/tests/scanner/typedefs.h
@@ -0,0 +1,73 @@
+#ifndef __TYPEDEFS_H__
+#define __TYPEDEFS_H__
+
+#include <glib-object.h>
+
+/*
+ * Tests for various orderings of typedef struct declarations.
+ */
+
+
+typedef struct {
+ int value;
+} TypedefsStructWithAnonymousTypedef;
+
+
+typedef struct _TypedefsStructWithTypedefBefore TypedefsStructWithTypedefBefore;
+struct _TypedefsStructWithTypedefBefore {
+ int value;
+};
+
+
+/* BUG: produces name with underscore prefix */
+struct _TypedefsStructWithTypedefAfter {
+ int value;
+};
+typedef struct _TypedefsStructWithTypedefAfter TypedefsStructWithTypedefAfter;
+
+
+/* BUG: produces name with underscore prefix */
+typedef struct _TypedefsStructWithTagAndTypedef {
+ int value;
+} TypedefsStructWithTagAndTypedef;
+
+
+/*
+ * Boxed versions of typedef ordering tests.
+ */
+
+typedef struct _TypedefsBoxedWithTypedefBefore TypedefsBoxedWithTypedefBefore;
+struct _TypedefsBoxedWithTypedefBefore {
+ int value;
+};
+GType typedefs_boxed_with_typedef_before_get_type (void) G_GNUC_CONST;
+
+
+/* BUG: struct has no fields in GIR */
+struct _TypedefsBoxedWithTypedefAfter {
+ int value;
+};
+typedef struct _TypedefsBoxedWithTypedefAfter TypedefsBoxedWithTypedefAfter;
+GType typedefs_boxed_with_typedef_after_get_type (void) G_GNUC_CONST;
+
+
+/* BUG: struct has no fields and extra <record> with underscore prefix */
+typedef struct _TypedefsBoxedWithTagAndTypedef {
+ int value;
+} TypedefsBoxedWithTagAndTypedef;
+GType typedefs_boxed_with_tag_and_typedef_get_type (void) G_GNUC_CONST;
+
+
+/* BUG: extra <record> with underscore prefix */
+typedef struct {
+ int value;
+} TypedefsBoxedWithAnonymousTypedef;
+GType typedefs_boxed_with_anonymous_typedef_get_type (void) G_GNUC_CONST;
+
+
+/* BUG: uses <record> instead of <glib:boxed> */
+typedef struct _TypedefsBoxedWithHiddenStruct TypedefsBoxedWithHiddenStruct;
+GType typedefs_boxed_with_hidden_struct_get_type (void) G_GNUC_CONST;
+
+
+#endif /*__TYPEDEFS_H__*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]