[gtk-doc] scan: add tests for unions and fix detecting top-level unions
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] scan: add tests for unions and fix detecting top-level unions
- Date: Mon, 26 Nov 2018 20:01:12 +0000 (UTC)
commit 1cc84de11709de693baf4d94afac56f6a345d90b
Author: Stefan Sauer <ensonic users sf net>
Date: Mon Nov 26 19:42:49 2018 +0100
scan: add tests for unions and fix detecting top-level unions
gtkdoc/scan.py | 2 +-
tests/scan.py | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index 8ecd859..5c2719f 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -437,7 +437,7 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
m19 = re.search(r'^\s*([A-Za-z]\w*)\s*\(', line)
m20 = re.search(r'^\s*\(', line)
m21 = re.search(r'^\s*struct\s+_?(\w+)', line)
- m22 = re.search(r'^\s*union\s+_(\w+)', line)
+ m22 = re.search(r'^\s*union\s+_?(\w+)', line)
# MACROS
diff --git a/tests/scan.py b/tests/scan.py
index d2f133a..16d7018 100644
--- a/tests/scan.py
+++ b/tests/scan.py
@@ -194,8 +194,44 @@ class ScanHeaderContentStructs(ScanHeaderContentTestCase):
self.assertDecl('data', header)
+class ScanHeaderContentUnions(ScanHeaderContentTestCase):
+ """Test parsing of Union declarations."""
+
+ def assertDecl(self, name, decl):
+ d = '<UNION>\n<NAME>%s</NAME>\n%s</UNION>\n' % (name, decl)
+ self.assertEqual([d], self.decls)
+ self.assertEqual([], self.types)
+
+ def test_FindsUnion(self):
+ header = textwrap.dedent("""\
+ union data {
+ int i;
+ float f;
+ };""")
+ slist, doc_comments = self.scanHeaderContent(
+ header.splitlines(keepends=True))
+ self.assertDecl('data', header)
+
+ def test_FindsTypedefUnion(self):
+ header = textwrap.dedent("""\
+ typedef union {
+ int i;
+ float f;
+ } Data;""")
+ slist, doc_comments = self.scanHeaderContent(
+ header.splitlines(keepends=True))
+ self.assertDecl('Data', header)
+
+
# VARIABLE
if __name__ == '__main__':
unittest.main()
+
+ # from gtkdoc import common
+ # common.setup_logging()
+ #
+ # t = ScanHeaderContentUnions()
+ # t.setUp()
+ # t.test_FindsUnion()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]