diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-09-26 20:30:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-09-27 21:04:22 -0400 |
commit | fc1134e3e59df2ca473e787f70a57ebf659d78f2 (patch) | |
tree | 8aa75eaf91bdf23eb7ec1c7ef4d39d51502fcca2 /scripts | |
parent | 21c9f7c85e90f4d3ef539d41a36a24b2f26ad3d1 (diff) | |
download | tor-fc1134e3e59df2ca473e787f70a57ebf659d78f2.tar.gz tor-fc1134e3e59df2ca473e787f70a57ebf659d78f2.zip |
annotate_ifdef_directives: test edge-case of 80-char line
An 80-character line (79 characters if you don't count the newline)
should not be truncated, and should not have a "..." insterted.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maint/annotate_ifdef_directives.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/maint/annotate_ifdef_directives.py b/scripts/maint/annotate_ifdef_directives.py index b4326f9822..102128bfa0 100755 --- a/scripts/maint/annotate_ifdef_directives.py +++ b/scripts/maint/annotate_ifdef_directives.py @@ -156,6 +156,22 @@ def commented_line(fmt, argument, maxwidth=LINE_WIDTH): '#endif /* long long long long long long ' >>> long_line[40:] 'long long long long long long lon... */\n' + + If a line works out to being 80 characters naturally, it isn't truncated, + and no ellipsis is added. + + >>> medium_argument = "a"*66 + >>> medium_line = commented_line("#endif /* %s */\n", medium_argument) + >>> len(medium_line) + 80 + >>> "..." in medium_line + False + >>> medium_line[:40] + '#endif /* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + >>> medium_line[40:] + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa */\n' + + """ assert fmt.endswith("\n") result = fmt % argument |