From 28682e57c0eb4e14ce745f2c6a0e9151934d9c81 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sun, 8 Mar 2026 18:25:55 +0100 Subject: [PATCH] add test_editor_load_markdown_para1 --- application/tests/test-editor.c | 28 +++++++++++++++++++++++++++- application/tests/test-editor.h | 1 + application/tests/testmain.c | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/application/tests/test-editor.c b/application/tests/test-editor.c index 440cf4b..ce322f0 100644 --- a/application/tests/test-editor.c +++ b/application/tests/test-editor.c @@ -352,7 +352,7 @@ CX_TEST(test_mddoc_linearization) { CX_TEST(test_editor_load_markdown_simple) { CX_TEST_DO { - UiObject *obj = ui_simple_window("test1"); + UiObject *obj = ui_simple_window("test"); CxAllocator *a = ui_allocator(obj->ctx); Note note; @@ -373,3 +373,29 @@ CX_TEST(test_editor_load_markdown_simple) { ui_close(obj); } } + +CX_TEST(test_editor_load_markdown_para1) { + CX_TEST_DO { + UiObject *obj = ui_simple_window("test"); + 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); + + cxmutstr md0 = cx_mutstr("Hello World\n\nParagraph 2"); + + editor_load_markdown(¬e, textview, md0); + cxmutstr mdtext = editor_get_markdown(text, a); + CX_TEST_ASSERT(!cx_strcmp(cx_strtrim(mdtext), md0)); + + // TODO: cleanup + ui_close(obj); + } +} diff --git a/application/tests/test-editor.h b/application/tests/test-editor.h index 06b34ec..641af2c 100644 --- a/application/tests/test-editor.h +++ b/application/tests/test-editor.h @@ -42,6 +42,7 @@ CX_TEST(test_parse_markdown_list); CX_TEST(test_mddoc_linearization); CX_TEST(test_editor_load_markdown_simple); +CX_TEST(test_editor_load_markdown_para1); #ifdef __cplusplus } diff --git a/application/tests/testmain.c b/application/tests/testmain.c index 0d7c626..3e650c7 100644 --- a/application/tests/testmain.c +++ b/application/tests/testmain.c @@ -83,6 +83,7 @@ int main(int argc, char **argv) { cx_test_register(suite, test_mddoc_linearization); cx_test_register(suite, test_editor_load_markdown_simple); + cx_test_register(suite, test_editor_load_markdown_para1); cx_test_register(suite, test_text_search_strcasestr); cx_test_register(suite, test_text_search_cs); -- 2.47.3