diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2017-04-17 10:07:31 +0200 |
---|---|---|
committer | Sebastian Hahn <sebastian@torproject.org> | 2017-04-17 10:10:46 +0200 |
commit | 5a7e39c0cbca3f2b94834167154472a61fc34a03 (patch) | |
tree | 53be033d4c00aa3d04d0e9b02aa82a38eb61f7bd /src/test/test_consdiff.c | |
parent | b081a7ed21ae729f6e195715e130edaca3e0b7fe (diff) | |
download | tor-5a7e39c0cbca3f2b94834167154472a61fc34a03.tar.gz tor-5a7e39c0cbca3f2b94834167154472a61fc34a03.zip |
Fix diff generation with line added at start
The consdiff generation logic would skip over lines added at the start of the
second file, and generate a diff that it would the immediately refuse because
it couldn't be used to reproduce the second file from the first. Fixes #21996.
Diffstat (limited to 'src/test/test_consdiff.c')
-rw-r--r-- | src/test/test_consdiff.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/test_consdiff.c b/src/test/test_consdiff.c index 1b4e2ad3c1..193d524c81 100644 --- a/src/test/test_consdiff.c +++ b/src/test/test_consdiff.c @@ -622,6 +622,17 @@ test_consdiff_gen_ed_diff(void *arg) tt_str_eq_line(".", smartlist_get(diff, 5)); tt_str_eq_line("2d", smartlist_get(diff, 6)); + smartlist_clear(cons1); + smartlist_clear(cons2); + consensus_split_lines(cons1, "B\n", area); + consensus_split_lines(cons2, "A\nB\n", area); + diff = gen_ed_diff(cons1, cons2, area); + tt_ptr_op(NULL, OP_NE, diff); + tt_int_op(3, OP_EQ, smartlist_len(diff)); + tt_str_eq_line("0a", smartlist_get(diff, 0)); + tt_str_eq_line("A", smartlist_get(diff, 1)); + tt_str_eq_line(".", smartlist_get(diff, 2)); + /* TODO: small real use-cases, i.e. consensuses. */ done: |