]> uap-core.de Git - note.git/commitdiff
add test_editor_load_markdown_simple
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 7 Mar 2026 19:35:32 +0000 (20:35 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sat, 7 Mar 2026 19:35:32 +0000 (20:35 +0100)
application/gtk-text.c
application/tests/test-editor.c
application/tests/test-editor.h
application/tests/testmain.c

index 6b5dc9a7ea5efc745dd73a7f69917df0ad9527f7..b747251c2a24c647a051ccf74682dd48f226d941 100644 (file)
@@ -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);
index 4683eb7f6508534908c8ba3148d50c9d69aa0465..440cf4bd725e871540b8ea05fb9f55a626d83cd6 100644 (file)
@@ -29,6 +29,7 @@
 #include "test-editor.h"
 
 #include "../editor.h"
+#include "../note.h"
 
 #include <cx/compare.h>
 
@@ -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(&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);
+        
+        editor_load_markdown(&note, 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);
+    }
+}
index c0494513759aa060ecd295a333f93d8cf5c2b00e..06b34ec6fd945c94532f2a09dcc8cab744489ebf 100644 (file)
@@ -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
index e5f7d99b18c5514385e1bae5f02ed6b02eee6fb6..0d7c626c41a3478fe781b99c425cb565afd44694 100644 (file)
@@ -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);