mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Add test for summary truncating long anotations
When calling summary command with :annotations hint, if the annotation is longer than a certain length, it's going to be truncated. The issue is that the length and truncation are done on a raw string without considering UTF8 multibyte characters, so there are edge cases when an annotation is truncated in the middle of a character creating an invalid UTF8 string. Added a test case for this scenario. Signed-off-by: Maxim Beder <macsim.beder@gmail.com>
This commit is contained in:
parent
c85e0c01ca
commit
68d4978b7d
1 changed files with 10 additions and 0 deletions
|
@ -352,6 +352,16 @@ W\d{1,2} \d{4}-\d{2}-\d{2} .{3} ?0:00:00 0:00:00 0:00:00 0:00:00
|
|||
[ ]+0:00:00
|
||||
""")
|
||||
|
||||
def test_multibyte_char_annotation_truncated(self):
|
||||
"""Summary correctly truncates long annotation containing multibyte characters"""
|
||||
# Using a blue heart emoji as an example of a multibyte (4 bytes in
|
||||
# this case) character.
|
||||
long_enough_annotation = "a" + "\N{blue heart}" * 20
|
||||
self.t("track FOO sod - sod")
|
||||
self.t("anno @1 " + long_enough_annotation)
|
||||
code, out, err = self.t("summary :anno")
|
||||
self.assertIn("a" + "\N{blue heart}" * 11 + "...", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue