This isn't actually something that Tor does, but it's cleaner to do
it this way. Part of 29746.
"""Get number of #include statements in the file"""
include_count = 0
for line in f:
- if re.match(r' *# *include', line):
+ if re.match(r'\s*#\s*include', line):
include_count += 1
return include_count
for name, lines in metrics.get_function_lines(funcs):
self.assertEqual(lines, 4)
+class TestIncludeCount(unittest.TestCase):
+ def test_include_count(self):
+ f = StringIO.StringIO("""
+ # include <abc.h>
+ # include "def.h"
+#include "ghi.h"
+\t#\t include "jkl.h"
+""")
+ self.assertEqual(metrics.get_include_count(f),4)
+
if __name__ == '__main__':
unittest.main()