#undef NDEBUG
#include <assert.h>
#define NO_VIM_MAIN
#include "main.c"
#include "message.c"
static void
test_trunc_string(void)
{
char_u *buf;
char_u *s;
buf = alloc(40);
STRCPY(buf, "text");
trunc_string(buf, buf, 20, 40);
assert(STRCMP(buf, "text") == 0);
vim_free(buf);
buf = alloc(40);
STRCPY(buf, "a short text");
trunc_string(buf, buf, 20, 40);
assert(STRCMP(buf, "a short text") == 0);
vim_free(buf);
buf = alloc(40);
STRCPY(buf, "a text tha just fits");
trunc_string(buf, buf, 20, 40);
assert(STRCMP(buf, "a text tha just fits") == 0);
vim_free(buf);
buf = alloc(40);
STRCPY(buf, "a text that nott fits");
trunc_string(buf, buf, 20, 40);
assert(STRCMP(buf, "a text t...nott fits") == 0);
vim_free(buf);
buf = alloc(40);
s = vim_strsave((char_u *)"text");
trunc_string(s, buf, 20, 40);
assert(STRCMP(buf, "text") == 0);
vim_free(buf);
vim_free(s);
buf = alloc(40);
s = vim_strsave((char_u *)"a text that fits");
trunc_string(s, buf, 34, 40);
assert(STRCMP(buf, "a text that fits") == 0);
vim_free(buf);
vim_free(s);
buf = alloc(40);
s = vim_strsave((char_u *)"a short text");
trunc_string(s, buf, 20, 40);
assert(STRCMP(buf, "a short text") == 0);
vim_free(buf);
vim_free(s);
buf = alloc(40);
s = vim_strsave((char_u *)"a text tha just fits");
trunc_string(s, buf, 20, 40);
assert(STRCMP(buf, "a text tha just fits") == 0);
vim_free(buf);
vim_free(s);
buf = alloc(40);
s = vim_strsave((char_u *)"a text that nott fits");
trunc_string(s, buf, 20, 40);
assert(STRCMP(buf, "a text t...nott fits") == 0);
vim_free(buf);
vim_free(s);
}
int
main(int argc, char **argv)
{
vim_memset(¶ms, 0, sizeof(params));
params.argc = argc;
params.argv = argv;
common_init(¶ms);
init_chartab();
test_trunc_string();
return 0;
}