[gtk-doc] scan: add more tests for the subsection logic



commit b47f3dcf32f4608dfd32e56f94ce06c7b46f1906
Author: Stefan Sauer <ensonic users sf net>
Date:   Sat Feb 2 21:14:21 2019 +0100

    scan: add more tests for the subsection logic
    
    Add tests verifying handling of gobject related symbols.

 tests/scan.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 72 insertions(+), 1 deletion(-)
---
diff --git a/tests/scan.py b/tests/scan.py
index 787b418..f1468fa 100755
--- a/tests/scan.py
+++ b/tests/scan.py
@@ -655,12 +655,83 @@ class ScanHeaderContentTypedefs(ScanHeaderContentTestCase):
         self.assertNoDeclFound(slist)
 
 
-class SeparateSubSectionsTestCase(unittest.TestCase):
+class SeparateSubSectionsTestCase(ScanHeaderContentTestCase):
 
     def test_NoSymbolsGiveEmptyResult(self):
         liststr = scan.SeparateSubSections([], {})
         self.assertEqual('\n', liststr)
 
+    def test_CreatesStandardSectionFromIsObjectMacro(self):
+        header = textwrap.dedent("""\
+            #define GTKDOC_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTKDOC_TYPE_OBJECT))
+            void gtkdoc_object_function(void);
+            """)
+        slist, doc_comments = self.scanHeaderContent(
+            header.splitlines(keepends=True))
+        liststr = scan.SeparateSubSections(slist, doc_comments)
+        self.assertEqual(
+            ['gtkdoc_object_function', '<SUBSECTION Standard>', 'GTKDOC_IS_OBJECT'],
+            liststr.splitlines())
+
+    def test_CreatesStandardSectionFromIsObjectClassMacro(self):
+        header = textwrap.dedent("""\
+            #define GTKDOC_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTKDOC_TYPE_OBJECT))
+            void gtkdoc_object_function(void);
+            """)
+        slist, doc_comments = self.scanHeaderContent(
+            header.splitlines(keepends=True))
+        liststr = scan.SeparateSubSections(slist, doc_comments)
+        self.assertEqual(
+            ['gtkdoc_object_function', '<SUBSECTION Standard>', 'GTKDOC_IS_OBJECT_CLASS'],
+            liststr.splitlines())
+
+    def test_CreatesStandardSectionFromGetTypeFunction(self):
+        header = textwrap.dedent("""\
+            GType gtkdoc_object_get_type(void) G_GNUC_CONST;
+            void gtkdoc_object_function(void);
+            """)
+        slist, doc_comments = self.scanHeaderContent(
+            header.splitlines(keepends=True))
+        liststr = scan.SeparateSubSections(slist, doc_comments)
+        self.assertEqual(
+            ['gtkdoc_object_function', '<SUBSECTION Standard>', 'gtkdoc_object_get_type'],
+            liststr.splitlines())
+
+    def test_MovesSymbolIfUndocumented(self):
+        header = textwrap.dedent("""\
+            struct _GtkdocObject {
+              GObject parent;
+            };
+            GType gtkdoc_object_get_type(void) G_GNUC_CONST;
+            void gtkdoc_object_function(void);
+            """)
+        slist, doc_comments = self.scanHeaderContent(
+            header.splitlines(keepends=True))
+        liststr = scan.SeparateSubSections(slist, doc_comments)
+        self.assertEqual(
+            ['gtkdoc_object_function', '<SUBSECTION Standard>', 'GtkdocObject', 'gtkdoc_object_get_type'],
+            liststr.splitlines())
+
+    def test_DoesNotMoveSymbolIfDocumented(self):
+        header = textwrap.dedent("""\
+            /**
+             * GtkdocObject:
+             *
+             * instance data of gtk-doc unit test class
+             */
+            struct _GtkdocObject {
+              GObject parent;
+            };
+            GType gtkdoc_object_get_type(void) G_GNUC_CONST;
+            void gtkdoc_object_function(void);
+            """)
+        slist, doc_comments = self.scanHeaderContent(
+            header.splitlines(keepends=True))
+        liststr = scan.SeparateSubSections(slist, doc_comments)
+        self.assertEqual(
+            ['GtkdocObject', 'gtkdoc_object_function', '<SUBSECTION Standard>', 'gtkdoc_object_get_type'],
+            liststr.splitlines())
+
 
 if __name__ == '__main__':
     unittest.main()


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