Skip to content

Commit 9c4b246

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.0666: assert_equal() doesn't show multibyte string correctly
Problem: assert_equal() doesn't show multibyte string correctly Solution: Properly advance over a multibyte char. (zeertzjq) closes: #15456 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 0cc5dce commit 9c4b246

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/testdir/test_assert.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,19 @@ func Test_assert_equal()
4848
call assert_match("Expected 'bar' but got 'foo'", v:errors[0])
4949
call remove(v:errors, 0)
5050

51+
let s = 'αβγ'
52+
call assert_equal(1, assert_equal('δεζ', s))
53+
call assert_match("Expected 'δεζ' but got 'αβγ'", v:errors[0])
54+
call remove(v:errors, 0)
55+
5156
call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX')
5257
call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0])
5358
call remove(v:errors, 0)
5459

60+
call assert_equal('ΩωωωωωωωωωωωωωωωωωωωωωΩ', 'ΩψψψψψψψψψψψψψψψψψψψψψψψψψΩ')
61+
call assert_match("Expected 'Ω\\\\\\[ω occurs 21 times]Ω' but got 'Ω\\\\\\[ψ occurs 25 times]Ω'", v:errors[0])
62+
call remove(v:errors, 0)
63+
5564
" special characters are escaped
5665
call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x')
5766
call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''x''', v:errors[0])

src/testing.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ga_concat_shorten_esc(garray_T *gap, char_u *str)
9999
return;
100100
}
101101

102-
for (p = str; *p != NUL; ++p)
102+
for (p = str; *p != NUL; )
103103
{
104104
same_len = 1;
105105
s = p;
@@ -118,10 +118,13 @@ ga_concat_shorten_esc(garray_T *gap, char_u *str)
118118
vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
119119
ga_concat(gap, buf);
120120
ga_concat(gap, (char_u *)" times]");
121-
p = s - 1;
121+
p = s;
122122
}
123123
else
124+
{
124125
ga_concat_esc(gap, p, clen);
126+
p += clen;
127+
}
125128
}
126129
}
127130

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
666,
707709
/**/
708710
665,
709711
/**/

0 commit comments

Comments
 (0)