aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_signatures.cpp
AgeCommit message (Collapse)AuthorFilesLines
17 hoursfix(signatures): match the guard against on-disk text, newline and allDanilo M.1-0/+17
The guard compared the buffer block, with trailing blank lines trimmed, against knownSignatures() values returned verbatim by text(), which carry the trailing newline every editor writes. The two never compared equal, so a signature read back from disk was always treated as unknown: switching appended a second signature instead of replacing, and None removed nothing. Normalise each known entry the same way the block scan does, once in replace(), rather than per comparison. Part of item 152.
18 hourstest(signatures): record what the quoted-delimiter test does not pinDanilo M.1-0/+10
The test asserts that a delimiter inside the quoted original is not treated as this message's signature, and it passes whether or not the code checks for that. Two mutations were measured against it and both stayed green: trimming the delimiter comparison so a quoted "> -- " matches, and making the quoted text one of the known signatures so the match guard could not be what refuses the removal. Neither changes the output. blockEnd() stops the block at the quote, so the quoted signature survives either way, and the behaviour is correct under both. The comment says so, so the next reader does not spend the same measurements discovering that the test cannot be sharpened. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEcn3u19xPqv6ggD15PG4c
18 hoursfeat(signatures): replace an existing signature, guarded by a matchDanilo M.1-0/+101
Finding a "-- " delimiter is not authority to delete what follows it. The block is replaced only when its text matches one of the signatures on disk, and otherwise the new one is inserted with nothing removed, so a wrong guess adds a visible duplicate rather than destroying the user's writing. A quoted delimiter is never the signature either: the quoted original carries the other party's, and it is not this message's to replace. The block's lower boundary is quoteStart(), not the first quoted line. The attribution introduces the quote and belongs with it, so scanning for '>' alone swallowed "On Mon, someone wrote:" into the signature block: it then matched no known signature, and had it matched, removal would have stranded the attribution above the text it introduces. The boundary the insertion uses and the boundary the removal uses have to be the same one. The guard's test was mutation-checked by making the match unconditional, which fails it. Part of item 152.
18 hoursfeat(signatures): splice a signature into a bufferDanilo M.1-0/+62
Both placements over one implementation. above_quote inserts before the attribution rather than before the first quoted line: the attribution introduces the quote and belongs with it, and a signature between the two would read as part of the quoted message. A buffer with no quote makes above_quote identical to end, so a new message needs no branch of its own. Part of item 152. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEcn3u19xPqv6ggD15PG4c
18 hoursfeat(signatures): read a directory of markdown signaturesDanilo M.1-0/+104
One file per signature under a directory the caller names, the stem being the name shown to the user. A name containing a path separator is refused: it arrives from the config file, and it reaches a path that is read into a message about to be sent. Part of item 152. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KEcn3u19xPqv6ggD15PG4c