1 /* vi:set ts=8 sts=4 sw=4 noet:
3 * VIM - Vi IMproved by Bram Moolenaar
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
11 * message_test.c: Unittests for message.c
17 /* Must include main.c because it contains much more than just main() */
21 /* This file has to be included because some of the tested functions are
26 * Test trunc_string().
29 test_trunc_string(void)
31 char_u *buf; /*allocated every time to find uninit errors */
37 trunc_string(buf, buf, 20, 40);
38 assert(STRCMP(buf, "text") == 0);
42 STRCPY(buf, "a short text");
43 trunc_string(buf, buf, 20, 40);
44 assert(STRCMP(buf, "a short text") == 0);
48 STRCPY(buf, "a text tha just fits");
49 trunc_string(buf, buf, 20, 40);
50 assert(STRCMP(buf, "a text tha just fits") == 0);
54 STRCPY(buf, "a text that nott fits");
55 trunc_string(buf, buf, 20, 40);
56 assert(STRCMP(buf, "a text t...nott fits") == 0);
59 /* copy from string to buf */
61 s = vim_strsave((char_u *)"text");
62 trunc_string(s, buf, 20, 40);
63 assert(STRCMP(buf, "text") == 0);
68 s = vim_strsave((char_u *)"a text that fits");
69 trunc_string(s, buf, 34, 40);
70 assert(STRCMP(buf, "a text that fits") == 0);
75 s = vim_strsave((char_u *)"a short text");
76 trunc_string(s, buf, 20, 40);
77 assert(STRCMP(buf, "a short text") == 0);
82 s = vim_strsave((char_u *)"a text tha just fits");
83 trunc_string(s, buf, 20, 40);
84 assert(STRCMP(buf, "a text tha just fits") == 0);
89 s = vim_strsave((char_u *)"a text that nott fits");
90 trunc_string(s, buf, 20, 40);
91 assert(STRCMP(buf, "a text t...nott fits") == 0);
97 main(int argc, char **argv)
99 vim_memset(¶ms, 0, sizeof(params));
102 common_init(¶ms);