]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0666: assert_equal() doesn't show multibyte string correctly v9.1.0666
authorzeertzjq <zeertzjq@outlook.com>
Fri, 9 Aug 2024 17:52:10 +0000 (19:52 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 9 Aug 2024 17:52:10 +0000 (19:52 +0200)
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>
src/testdir/test_assert.vim
src/testing.c
src/version.c

index d143f19f59dcb3a5cb9343039a6e65263443fc94..15b18a4423e547dd1d40a6e2b6f5b1c8f00b3307 100644 (file)
@@ -48,10 +48,19 @@ func Test_assert_equal()
   call assert_match("Expected 'bar' but got 'foo'", v:errors[0])
   call remove(v:errors, 0)
 
+  let s = 'αβγ'
+  call assert_equal(1, assert_equal('δεζ', s))
+  call assert_match("Expected 'δεζ' but got 'αβγ'", v:errors[0])
+  call remove(v:errors, 0)
+
   call assert_equal('XxxxxxxxxxxxxxxxxxxxxxX', 'XyyyyyyyyyyyyyyyyyyyyyyyyyX')
   call assert_match("Expected 'X\\\\\\[x occurs 21 times]X' but got 'X\\\\\\[y occurs 25 times]X'", v:errors[0])
   call remove(v:errors, 0)
 
+  call assert_equal('ΩωωωωωωωωωωωωωωωωωωωωωΩ', 'ΩψψψψψψψψψψψψψψψψψψψψψψψψψΩ')
+  call assert_match("Expected 'Ω\\\\\\[ω occurs 21 times]Ω' but got 'Ω\\\\\\[ψ occurs 25 times]Ω'", v:errors[0])
+  call remove(v:errors, 0)
+
   " special characters are escaped
   call assert_equal("\b\e\f\n\t\r\\\x01\x7f", 'x')
   call assert_match('Expected ''\\b\\e\\f\\n\\t\\r\\\\\\x01\\x7f'' but got ''x''', v:errors[0])
index 18b8e788eb7f262c758d116f1858e38c3ec9f65e..7ab109c10ca545b60cb0286b14dd13c8cd74ecec 100644 (file)
@@ -99,7 +99,7 @@ ga_concat_shorten_esc(garray_T *gap, char_u *str)
        return;
     }
 
-    for (p = str; *p != NUL; ++p)
+    for (p = str; *p != NUL; )
     {
        same_len = 1;
        s = p;
@@ -118,10 +118,13 @@ ga_concat_shorten_esc(garray_T *gap, char_u *str)
            vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
            ga_concat(gap, buf);
            ga_concat(gap, (char_u *)" times]");
-           p = s - 1;
+           p = s;
        }
        else
+       {
            ga_concat_esc(gap, p, clen);
+           p += clen;
+       }
     }
 }
 
index 1b7e423353c4e7a2c235d167b7baeeb13eba2072..1aacff5e66ca763d089a524088d0fbfe70ddde5d 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    666,
 /**/
     665,
 /**/