diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2019-07-24 19:12:36 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2019-07-24 21:53:47 +0200 |
commit | f19b91f2ae25f0fc2881e7414316d89a0678c9fb (patch) | |
tree | 7a50d4a0f1e4f97b22c0e2241e02f58097c66058 /tests/scan.py | |
parent | 2b40491bf8d37cd6766f289dd2c309f0d6a658d3 (diff) | |
download | gtk-doc-f19b91f2ae25f0fc2881e7414316d89a0678c9fb.tar.gz |
mkdb: fix skipping of inline function bodies
Add a bunch of tests for this.
Fixes #90
Diffstat (limited to 'tests/scan.py')
-rwxr-xr-x | tests/scan.py | 90 |
1 files changed, 85 insertions, 5 deletions
diff --git a/tests/scan.py b/tests/scan.py index 98fddf7..77ddf3a 100755 --- a/tests/scan.py +++ b/tests/scan.py @@ -832,15 +832,95 @@ class SeparateSubSections(ScanHeaderContentTestCase): liststr.splitlines()) +class RemoveBracedContent(ScanHeaderContentTestCase): + + def test_OneLineFunctionBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int function(int a) { return a + a; }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int function(int a);", decl) + self.assertEqual(skip, False) + + def test_SimpleFunctionBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int function(int a) { + return a + a; + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int function(int a);", decl) + self.assertEqual(skip, False) + + def test_SimpleFunctionWithNewlineBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int function(int a) + { + return a + a; + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int function(int a);", decl) + self.assertEqual(skip, False) + + def test_NestedFunctionBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int function(int a) { + if (a > 0) { + return a + a; + } else { + return a - a; + } + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int function(int a);", decl) + self.assertEqual(skip, False) + + def test_NestedFunctionWithNewlinesBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int function(int a) + { + if (a > 0) + { + return a + a; + } + else + { + return a - a; + } + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int function(int a);", decl) + self.assertEqual(skip, False) + + def test_SimpleFunctionWithParenthesisBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int + (function) (int a) + { + return a + a; + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual("static inline int\n(function) (int a);", decl) + self.assertEqual(skip, False) + + def test_FunctionWithMultilineParamsBodyIsRemoved(self): + decl = textwrap.dedent("""\ + static inline int + function (int a, + int b) + { + return a + b; + }""") + (skip, decl) = scan.remove_braced_content(decl) + self.assertEqual( + "static inline int\nfunction (int a,\n int b);", decl) + self.assertEqual(skip, False) + + if __name__ == '__main__': from gtkdoc import common common.setup_logging() unittest.main() - # from gtkdoc import common - # common.setup_logging() - # - # t = ScanHeaderContentFunctions() + # t = RemoveBracedContent() # t.setUp() - # t.test_IgnoresInternalInlineFunction() + # t.test_NestedFunctionBodyIsRemoved() |