[gtk-doc] tests: add scan test or typedefs



commit 8b15ecf0741adf24d7c3345a258e8ce934b021d8
Author: Stefan Sauer <ensonic users sf net>
Date:   Fri Feb 1 07:55:38 2019 +0100

    tests: add scan test or typedefs

 gtkdoc/scan.py |  2 +-
 tests/scan.py  | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index edc0bbd..1cfe9e5 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -109,7 +109,7 @@ CLINE_MATCHER = [
         r"""^\s*
         (?:G_GNUC_EXTENSION\s+)?
         typedef\s+
-        (.+[\s\*])                           # 1:
+        (.+[\s\*])                           # 1: e.g. 'unsigned int'
         (\w+)                                # 2: name
         (?:\s*\[[^\]]+\])*
         \s*;""", re.VERBOSE),
diff --git a/tests/scan.py b/tests/scan.py
index ee3b296..869c546 100755
--- a/tests/scan.py
+++ b/tests/scan.py
@@ -617,6 +617,36 @@ class ScanHeaderContentVariabless(ScanHeaderContentTestCase):
         self.assertDecl('var', header, slist)
 
 
+class ScanHeaderContentTypedefs(ScanHeaderContentTestCase):
+    """Test parsing of typedef declarations."""
+
+    def assertDecl(self, name, decl, slist):
+        self.assertEqual([name], slist)
+        d = '<TYPEDEF>\n<NAME>%s</NAME>\n%s</TYPEDEF>\n' % (name, decl)
+        self.assertEqual([d], self.decls)
+        self.assertEqual([], self.types)
+
+    def test_FindsTypedefStructPointer(self):
+        header = 'typedef struct data *dataptr;'
+        slist, doc_comments = self.scanHeaderContent([header])
+        self.assertDecl('dataptr', header, slist)
+
+    def test_FindsTypedefUnionPointer(self):
+        header = 'typedef union data *dataptr;'
+        slist, doc_comments = self.scanHeaderContent([header])
+        self.assertDecl('dataptr', header, slist)
+
+    def test_FindsTypedef(self):
+        header = 'typedef unsigned int uint;'
+        slist, doc_comments = self.scanHeaderContent([header])
+        self.assertDecl('uint', header, slist)
+
+    def test_SkipsEnumTypedef(self):
+        header = 'typedef enum data dateenum;'
+        slist, doc_comments = self.scanHeaderContent([header])
+        self.assertNoDeclFound(slist)
+
+
 if __name__ == '__main__':
     unittest.main()
 


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