From 9722b8d4dc4e91996b24fc51f2a56df646e30cfb Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sat, 7 Mar 2026 20:35:32 +0100 Subject: [PATCH] add test_editor_load_markdown_simple --- application/gtk-text.c | 1 - application/tests/test-editor.c | 25 +++++++++++++++++++++++++ application/tests/test-editor.h | 2 ++ application/tests/testmain.c | 4 ++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/application/gtk-text.c b/application/gtk-text.c index 6b5dc9a..b747251 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -997,7 +997,6 @@ static void tagstyle_list0(MDActiveStyles *style, GtkTextTag *tag) { } void init_tagtable(GtkTextTagTable *table) { - printf("init_tagtable\n"); GtkTextTag *tag; tag = gtk_text_tag_new(EDITOR_STYLE_PARAGRAPH); diff --git a/application/tests/test-editor.c b/application/tests/test-editor.c index 4683eb7..440cf4b 100644 --- a/application/tests/test-editor.c +++ b/application/tests/test-editor.c @@ -29,6 +29,7 @@ #include "test-editor.h" #include "../editor.h" +#include "../note.h" #include @@ -348,3 +349,27 @@ CX_TEST(test_mddoc_linearization) { cxListFree(md.styles); } } + +CX_TEST(test_editor_load_markdown_simple) { + CX_TEST_DO { + UiObject *obj = ui_simple_window("test1"); + CxAllocator *a = ui_allocator(obj->ctx); + + Note note; + memset(¬e, 0, sizeof(Note)); + note.model = notemodel_create(a); + + UiText *text = note.model->text; + UIWIDGET textview = ui_textarea(obj, .value = text); + + editor_init_textview(obj, ui_textarea_gettextwidget(textview)); + editor_init_textbuf(text); + + editor_load_markdown(¬e, textview, cx_mutstr("Hello World")); + cxmutstr mdtext = editor_get_markdown(text, a); + CX_TEST_ASSERT(!cx_strcmp(cx_strtrim(mdtext), "Hello World")); + + // TODO: cleanup + ui_close(obj); + } +} diff --git a/application/tests/test-editor.h b/application/tests/test-editor.h index c049451..06b34ec 100644 --- a/application/tests/test-editor.h +++ b/application/tests/test-editor.h @@ -41,6 +41,8 @@ CX_TEST(test_parse_markdown_formatting_nested); CX_TEST(test_parse_markdown_list); CX_TEST(test_mddoc_linearization); +CX_TEST(test_editor_load_markdown_simple); + #ifdef __cplusplus } #endif diff --git a/application/tests/testmain.c b/application/tests/testmain.c index e5f7d99..0d7c626 100644 --- a/application/tests/testmain.c +++ b/application/tests/testmain.c @@ -39,6 +39,7 @@ #include "test-note.h" #include "../types.h" +#include "../editor.h" int main(int argc, char **argv) { setlocale(LC_ALL, "de_DE.UTF-8"); @@ -51,6 +52,7 @@ int main(int argc, char **argv) { ui_setappdir("notetestdata"); ui_init(NULL, 0, NULL); register_types(); + editor_global_init(); // required for testing async functions, that use ui_call_mainthread ui_buffer_mainthread_calls(TRUE); @@ -80,6 +82,8 @@ int main(int argc, char **argv) { cx_test_register(suite, test_parse_markdown_list); cx_test_register(suite, test_mddoc_linearization); + cx_test_register(suite, test_editor_load_markdown_simple); + cx_test_register(suite, test_text_search_strcasestr); cx_test_register(suite, test_text_search_cs); cx_test_register(suite, test_text_search_ci); -- 2.47.3