summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2011-08-18 17:29:21 +0200
committerGiovanni Campagna <gcampagna@src.gnome.org>2011-08-18 17:34:13 +0200
commitcbf0dc099aa335c95b554eb315a74ec9c3c8f8ae (patch)
tree0026fd8a36826ae16526edfbb67d09041679ce53
parentcf2ed9ffe5c01fc33d6402aae9c9a8ac6c737007 (diff)
downloadgobject-introspection-cbf0dc099aa335c95b554eb315a74ec9c3c8f8ae.tar.gz
Add tests for newly added warnings
g-ir-scanner now warns for invalid (element-type) annotations in GPtrArray and in GByteArray. Test that.
-rw-r--r--giscanner/maintransformer.py6
-rw-r--r--tests/warn/invalid-element-type.h28
2 files changed, 30 insertions, 4 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index dafdcade..397bb606 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -326,9 +326,9 @@ usage is void (*_gtk_reserved1)(void);"""
# (except enums and flags) or basic types that are
# as big as a gpointer
if array.array_type == ast.Array.GLIB_PTRARRAY and \
- ((array.element_type in ast.BASIC_GIR_TYPES \
- and not array.element_type in ast.POINTER_TYPES) or \
- isinstance(array.element_type, ast.Enum) or \
+ ((array.element_type in ast.BASIC_GIR_TYPES
+ and not array.element_type in ast.POINTER_TYPES) or
+ isinstance(array.element_type, ast.Enum) or
isinstance(array.element_type, ast.Bitfield)):
message.warn("invalid (element-type) for a GPtrArray, "
"must be a pointer", options.position)
diff --git a/tests/warn/invalid-element-type.h b/tests/warn/invalid-element-type.h
index f2cf2b93..2b424594 100644
--- a/tests/warn/invalid-element-type.h
+++ b/tests/warn/invalid-element-type.h
@@ -36,6 +36,28 @@ void test_invalid_hash_element_type(GHashTable *h1, GHashTable *h2, GHashTable *
// EXPECT:29: Warning: Test: element-type takes at maximium 2 values, 3 given
/**
+ * test_invalid_bytearray_element_type:
+ * @b1: (element-type):
+ * @b2: (element-type int):
+ */
+
+void test_invalid_bytearray_element_type(GByteArray *b1, GByteArray *b2);
+
+// EXPECT:40: Warning: Test: element-type annotation needs a value
+// EXPECT:40: Warning: Test: element-type takes at least one value, none given
+
+/**
+ * test_invalid_ptrarray_element_type:
+ * @p1: (element-type):
+ * @p2: (element-type int):
+ */
+
+void test_invalid_ptrarray_element_type(GPtrArray *p1, GPtrArray *p2);
+
+// EXPECT:51: Warning: Test: element-type annotation needs a value
+// EXPECT:51: Warning: Test: element-type takes at least one value, none given
+
+/**
* test_unresolved_element_type:
*
* Returns: (element-type Unresolved) (transfer full):
@@ -51,4 +73,8 @@ GList* test_unresolved_element_type(void);
// EXPECT:27: Warning: Test: element-type annotation takes at least one option, none given
// EXPECT:28: Warning: Test: element-type annotation for a hash table must have exactly two options, not 1 option(s)
// EXPECT:29: Warning: Test: element-type annotation for a hash table must have exactly two options, not 3 option(s)
-// EXPECT:41: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved'
+// EXPECT:40: Warning: Test: element-type annotation takes at least one option, none given
+// EXPECT:41: Warning: Test: invalid (element-type) for a GByteArray, must be one of guint8, gint8 or gchar
+// EXPECT:51: Warning: Test: element-type annotation takes at least one option, none given
+// EXPECT:52: Warning: Test: invalid (element-type) for a GPtrArray, must be a pointer
+// EXPECT:63: Warning: Test: test_unresolved_element_type: Unknown type: 'Unresolved'