]> uap-core.de Git - note.git/commitdiff
add test_editor_load_markdown_para1 main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 8 Mar 2026 17:25:55 +0000 (18:25 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 8 Mar 2026 17:25:55 +0000 (18:25 +0100)
application/tests/test-editor.c
application/tests/test-editor.h
application/tests/testmain.c

index 440cf4bd725e871540b8ea05fb9f55a626d83cd6..ce322f0463c4c5216c5e6f3d8eeb23457661b13a 100644 (file)
@@ -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(&note, 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(&note, textview, md0);
+        cxmutstr mdtext = editor_get_markdown(text, a);
+        CX_TEST_ASSERT(!cx_strcmp(cx_strtrim(mdtext), md0));
+        
+        // TODO: cleanup
+        ui_close(obj);
+    }
+}
index 06b34ec6fd945c94532f2a09dcc8cab744489ebf..641af2c6123e926d53ec8e9267392c4afdfcb582 100644 (file)
@@ -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
 }
index 0d7c626c41a3478fe781b99c425cb565afd44694..3e650c7af447bdc8c3549a16a15b3de5afdf020c 100644 (file)
@@ -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);