mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
test line joining
This commit is contained in:
parent
2847b751e3
commit
9d2429c027
@ -732,6 +732,7 @@ scripts/examples/Makefile
|
||||
tests/Makefile
|
||||
tests/fe-common/Makefile
|
||||
tests/fe-common/core/Makefile
|
||||
tests/fe-text/Makefile
|
||||
tests/irc/Makefile
|
||||
tests/irc/core/Makefile
|
||||
tests/irc/flood/Makefile
|
||||
|
@ -1 +1,5 @@
|
||||
SUBDIRS = fe-common irc
|
||||
if BUILD_TEXTUI
|
||||
TEXTUI=fe-text
|
||||
endif
|
||||
|
||||
SUBDIRS = fe-common irc $(TEXTUI)
|
||||
|
38
tests/fe-text/Makefile.am
Normal file
38
tests/fe-text/Makefile.am
Normal file
@ -0,0 +1,38 @@
|
||||
include $(top_srcdir)/utils/glib-tap.mk
|
||||
|
||||
PACKAGE_STRING=fe-text
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/src/fe-common/core \
|
||||
-I$(top_srcdir)/src/fe-text \
|
||||
$(GLIB_CFLAGS)
|
||||
|
||||
test_programs = test-paste-join-multiline
|
||||
|
||||
test_paste_join_multiline_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS)
|
||||
|
||||
# test_paste_join_multiline_DEPENDENCIES =
|
||||
|
||||
test_paste_join_multiline_LDADD = \
|
||||
../../src/fe-common/core/libfe_common_core.a \
|
||||
../../src/core/libcore.a \
|
||||
../../src/lib-config/libirssi_config.a \
|
||||
@PROG_LIBS@ \
|
||||
@TEXTUI_LIBS@
|
||||
|
||||
|
||||
test_paste_join_multiline_SOURCES = \
|
||||
../../src/fe-text/gui-entry.c \
|
||||
../../src/fe-text/mainwindows.c \
|
||||
../../src/fe-text/term-terminfo.c \
|
||||
../../src/fe-text/terminfo-core.c \
|
||||
../../src/fe-text/term.c \
|
||||
../../src/fe-text/textbuffer-view.c \
|
||||
../../src/fe-text/textbuffer.c \
|
||||
../../src/fe-text/gui-windows.c \
|
||||
../../src/fe-text/gui-printtext.c \
|
||||
mock-irssi.c \
|
||||
test-paste-join-multiline.c
|
9
tests/fe-text/mock-irssi.c
Normal file
9
tests/fe-text/mock-irssi.c
Normal file
@ -0,0 +1,9 @@
|
||||
void irssi_set_dirty(void)
|
||||
{
|
||||
}
|
||||
|
||||
void irssi_redraw(void)
|
||||
{
|
||||
}
|
||||
|
||||
int quitting = 0;
|
55
tests/fe-text/test-paste-join-multiline.c
Normal file
55
tests/fe-text/test-paste-join-multiline.c
Normal file
@ -0,0 +1,55 @@
|
||||
#include "common.h"
|
||||
#include "gui-readline.c"
|
||||
|
||||
typedef struct {
|
||||
char const *const description;
|
||||
char const *const input;
|
||||
char const *const result;
|
||||
} paste_join_multiline_test_case;
|
||||
|
||||
static void test_paste_join_multiline(const paste_join_multiline_test_case *test);
|
||||
|
||||
paste_join_multiline_test_case const paste_join_multiline_fixture[] = {
|
||||
{
|
||||
.description = "Lines should be joined, separator NL",
|
||||
.input = "<User> hello world\n how are you\n screen is narrow",
|
||||
.result = "<User> hello world how are you screen is narrow",
|
||||
},
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(paste_join_multiline_fixture); i++) {
|
||||
char *name = g_strdup_printf("/test/paste_join_multiline/%d", i);
|
||||
g_test_add_data_func(name, &paste_join_multiline_fixture[i], (GTestDataFunc)test_paste_join_multiline);
|
||||
g_free(name);
|
||||
}
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,38,0)
|
||||
g_test_set_nonfatal_assertions();
|
||||
#endif
|
||||
return g_test_run();
|
||||
}
|
||||
|
||||
static void test_paste_join_multiline(const paste_join_multiline_test_case *test)
|
||||
{
|
||||
char *resultstr;
|
||||
GArray *buffer = g_array_new(FALSE, FALSE, sizeof(unichar));
|
||||
|
||||
g_test_message("Testing: %s", test->description);
|
||||
|
||||
buffer->data = (char *) g_utf8_to_ucs4_fast(test->input, -1, (glong *) &buffer->len);
|
||||
paste_buffer_join_lines(buffer);
|
||||
resultstr = g_ucs4_to_utf8((unichar *) buffer->data, buffer->len, NULL, NULL, NULL);
|
||||
|
||||
g_assert_cmpstr(resultstr, ==, test->result);
|
||||
|
||||
g_free(resultstr);
|
||||
g_array_free(buffer, TRUE);
|
||||
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue
Block a user