annotate src/kword_test.c @ 13790:dd6a63e3e7c4 v8.0.1767

patch 8.0.1767: with 'incsearch' text may jump up and down commit https://github.com/vim/vim/commit/9d34d90210ba52ebaf45973282e5921f5af364c7 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 27 22:18:12 2018 +0200 patch 8.0.1767: with 'incsearch' text may jump up and down Problem: With 'incsearch' text may jump up and down. () Solution: Besides w_botline also save and restore w_empty_rows. (closes # 2530)
author Christian Brabandt <cb@256bit.org>
date Fri, 27 Apr 2018 22:30:06 +0200
parents ae1c6bf22e5f
children 536dd2bc5ac9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10724
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 *
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 *
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 /*
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 * kword_test.c: Unittests for vim_iswordc() and vim_iswordp().
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 #undef NDEBUG
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 #include <assert.h>
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 /* Must include main.c because it contains much more than just main() */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 #define NO_VIM_MAIN
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 #include "main.c"
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 /* This file has to be included because the tested functions are static */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 #include "charset.c"
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 #ifdef FEAT_MBYTE
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 /*
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 * Test the results of vim_iswordc() and vim_iswordp() are matched.
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 static void
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 test_isword_funcs_utf8(void)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 buf_T buf;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 int c;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 vim_memset(&buf, 0, sizeof(buf));
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 p_enc = (char_u *)"utf-8";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 p_isi = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 p_isp = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 p_isf = (char_u *)"";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 buf.b_p_isk = (char_u *)"@,48-57,_,128-167,224-235";
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 curbuf = &buf;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 mb_init(); /* calls init_chartab() */
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 for (c = 0; c < 0x10000; ++c)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 char_u p[4] = {0};
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 int c1;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 int retc;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 int retp;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 utf_char2bytes(c, p);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 c1 = utf_ptr2char(p);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 if (c != c1)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 fprintf(stderr, "Failed: ");
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 fprintf(stderr,
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 c, p[0], p[1], p[2]);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 fprintf(stderr, "c != utf_ptr2char(p) (=%#04x)\n", c1);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 abort();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 retc = vim_iswordc_buf(c, &buf);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 retp = vim_iswordp_buf(p, &buf);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 if (retc != retp)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 fprintf(stderr, "Failed: ");
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 fprintf(stderr,
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 "[c = %#04x, p = {%#02x, %#02x, %#02x}] ",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 c, p[0], p[1], p[2]);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 fprintf(stderr, "vim_iswordc(c) (=%d) != vim_iswordp(p) (=%d)\n",
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 retc, retp);
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 abort();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 }
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 #endif
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 int
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 main(void)
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 {
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 #ifdef FEAT_MBYTE
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 test_isword_funcs_utf8();
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 #endif
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 return 0;
ae1c6bf22e5f patch 8.0.0252: not properly recognizing word characters between 128 and 255
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 }