diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2018-11-26 07:39:09 +0100 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2018-11-26 21:00:30 +0100 |
commit | 5c5c6e49f6718095537f67059a61c0aa3b509d26 (patch) | |
tree | d914b3905684d9ab979016d51bf16c36413a138f /tests/scan.py | |
parent | eac6e4a231e6ac3e197ec4f1996c9a55f19b6a5e (diff) | |
download | gtk-doc-5c5c6e49f6718095537f67059a61c0aa3b509d26.tar.gz |
scan: add tests for structs
Use textwrap module to handle indentation of testdata.
Diffstat (limited to 'tests/scan.py')
-rw-r--r-- | tests/scan.py | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/tests/scan.py b/tests/scan.py index 2dab69d..2b0f6c1 100644 --- a/tests/scan.py +++ b/tests/scan.py @@ -19,6 +19,7 @@ # import argparse +import textwrap import unittest from gtkdoc import scan @@ -30,7 +31,9 @@ class ScanHeaderContentTestCase(unittest.TestCase): def setUp(self): self.decls = [] self.types = [] - self.options = argparse.Namespace(deprecated_guards='', ignore_decorators='') + self.options = argparse.Namespace( + deprecated_guards='GTKDOC_TESTER_DISABLE_DEPRECATED', + ignore_decorators='') def scanHeaderContent(self, content): return scan.ScanHeaderContent(content, self.decls, self.types, @@ -114,7 +117,47 @@ class ScanHeaderContentMacros(ScanHeaderContentTestCase): self.assertNoDeclFound(slist) -# STRUCT +class ScanHeaderContentStructs(ScanHeaderContentTestCase): + """Test parsing of struct declarations.""" + + def assertDecl(self, name, decl): + d = '<STRUCT>\n<NAME>%s</NAME>\n%s</STRUCT>\n' % (name, decl) + self.assertEqual([d], self.decls) + self.assertEqual([], self.types) + + def test_FindsStruct(self): + header = textwrap.dedent("""\ + struct data { + int test; + };""") + slist, doc_comments = self.scanHeaderContent( + header.splitlines(keepends=True)) + self.assertDecl('data', header) + + def test_FindsTypedefStruct(self): + header = textwrap.dedent("""\ + typedef struct { + int test; + } Data;""") + slist, doc_comments = self.scanHeaderContent( + header.splitlines(keepends=True)) + self.assertDecl('Data', header) + + def test_HandleStructWithDeprecatedMember(self): + header = textwrap.dedent("""\ + struct data { + int test_a; + #ifndef GTKDOC_TESTER_DISABLE_DEPRECATED + int deprecated; + #endif + int test_b; + };""") + slist, doc_comments = self.scanHeaderContent( + header.splitlines(keepends=True)) + self.assertDecl('data', header) + + +# VARIABLE if __name__ == '__main__': |