[gtk-doc] scan: actually add the test file :/



commit f4a67cb4afb86ae77b601eca70e78adb657b0f15
Author: Stefan Sauer <ensonic users sf net>
Date:   Mon Nov 19 21:11:35 2018 +0100

    scan: actually add the test file :/

 gtkdoc/scan.py |  5 ++--
 tests/scan.py  | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 2 deletions(-)
---
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index 2a2b4ba..f7c22fd 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -270,11 +270,10 @@ def ScanHeader(input_file, section_list, decl_list, get_types, seen_headers, opt
             section_list[file_basename] = ''
         section_list[file_basename] += "<SECTION>\n<FILE>%s</FILE>\n%s</SECTION>\n\n" % (file_basename, 
liststr)
 
+
 # Scan the the given content lines.
 # Returns: a list of symbols found and a set of symbols for which we have a
 #          doc-comment
-
-
 def ScanHeaderContent(input_lines, decl_list, get_types, options):
     # Holds the resulting list of declarations.
     slist = []
@@ -321,6 +320,8 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
 
     for line in input_lines:
         # If this is a private header, skip it.
+        # TODO: consider scanning this first, so that we don't modify: decl_list
+        # and get_types
         if re.search(r'^\s*/\*\s*<\s*private_header\s*>\s*\*/', line):
             return
 
diff --git a/tests/scan.py b/tests/scan.py
new file mode 100644
index 0000000..a58c9d2
--- /dev/null
+++ b/tests/scan.py
@@ -0,0 +1,76 @@
+# -*- python -*-
+#
+# gtk-doc - GTK DocBook documentation generator.
+# Copyright (C) 2017  Stefan Sauer
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+import argparse
+import unittest
+
+from gtkdoc import scan
+
+
+class ScanHeaderContent(unittest.TestCase):
+
+    def setUp(self):
+        self.decls = []
+        self.types = []
+        self.options = argparse.Namespace(deprecated_guards='')
+
+    def scanHeaderContent(self, content):
+        return scan.ScanHeaderContent(content, self.decls, self.types,
+                                      self.options)
+
+    def test_EmptyInput(self):
+        slist, doc_comments = self.scanHeaderContent([])
+        self.assertEqual([], slist)
+        self.assertEqual({}, doc_comments)
+        self.assertEqual([], self.decls)
+        self.assertEqual([], self.types)
+
+    def test_FindsDocComment(self):
+        slist, doc_comments = self.scanHeaderContent([
+            '/** FooBar:',
+            ' */'
+        ])
+        self.assertEqual(1, len(doc_comments))
+        self.assertIn('foobar', doc_comments)
+
+    def test_DocDoesNotChangeSlistDeclAndTypes(self):
+        slist, doc_comments = self.scanHeaderContent([
+            '/** FooBar:',
+            ' */'
+        ])
+        self.assertEqual([], slist)
+        self.assertEqual([], self.decls)
+        self.assertEqual([], self.types)
+
+    # test /* < private_header > */ maker
+
+    def test_SkipSymbolWithPreprocessor(self):
+        slist, doc_comments = self.scanHeaderContent([
+            '#ifndef __GTK_DOC_IGNORE__',
+            'extern int bug_512565(void);'
+            '#endif'
+        ])
+        self.assertEqual([], slist)
+        self.assertEqual([], self.decls)
+        self.assertEqual([], self.types)
+
+
+if __name__ == '__main__':
+    unittest.main()


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